unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Inclusion of XDG Base Directory library
@ 2018-05-06 19:04 Francisco Miguel Colaço
  2018-05-07  8:26 ` Francisco Miguel Colaço
  0 siblings, 1 reply; 8+ messages in thread
From: Francisco Miguel Colaço @ 2018-05-06 19:04 UTC (permalink / raw)
  To: Emacs Devel Mailing List

[-- Attachment #1: Type: text/plain, Size: 4221 bytes --]

  Friends,

  I have one again written a library to segregate user configuration
files among different concerns --- data, config, runtime and cache ---
following the XDG user directory specification.  I enclose the library.

  From the commentary in user-directories/user-directories.el

;; Following the XDG Base Directory Specification
;; (https://wiki.archlinux.org/index.php/XDG_Base_Directory_support),
;; user-directories strives to allow a package writer or an Emacs user
;; to segregate the various Emacs configuration and runtime files into
;; appropriate directories.
;;
;; Thus, following the specification, a configuration file (normally a
;; file that is written by the user or in behalf of him) will reside
;; in the configuration directory (normally ~/.config/emacs).  It ca
;; be located with:
;;
;;   (locate-user-config-file "init.el")
;;   "/home/fhc/.config/emacs/init.el"
;;
;; Similarly, there are locator functions for third party files ---
;; `locate-user-data-file' --- and for cache files ---
;; `locate-user-cache-file'.  Run time files, locatable with
;; `locate-user-runtime-files' will be erased at the last logout,
;; according to the specification, and are thus appropriate for
;; security-sensitive data.
;;
;; There are also directories defined for :documents, :music, :videos,
;; :pictures and :downloads.  In Linux, also other that the command
;; xdg-user-dir can reference, like :templates or :publicshare.
;; Locator functions are concomitantly created.  For instance, in one
;; of my machines (Linux, portuguese):
;;
;;   (locate-user-documents-file "org/index.txt")
;;   "/home/fhc/Documentos/org/index.txt"
;;
;;   (locate-user-pictures-file "image.png")
;;   "/home/fhc/Imagens/image.png"
;;
;; Emacs Lisp package writers may use the former functions to
;; segregate files among different concerns.  For instance:
;;
;;   (setq abbrev-file-name (locate-user-config-file "abbrev_defs"))
;;   (setq projectile-known-projects-file (locate-user-data-file
"projectile-bookmarks.eld"))
;;   (setq projectile-cache-file (locate-user-cache-file
"projectile.cache"))
;;

* HOW DO I INSTALL IT?

  Just including the two directories in a site-lisp directory is enough
on my machine to recognize ~/.config/emacs/init.el and run it at the
site start.

  Unfortunately, user-init-file will not be set, because I think it is
hardcoded in C from an array of possibilities.  However,
user-emacs-directory is correctly set, and thus all the files that would
be in ~/.emacs.d will be located by default at the :data directory ---
and elisp package writers can start to put all created files to the
correct directories, according to their concerns.

* WHAT ABOUT FREEBSD, OSX, ETC?

  Discovery is provided on Windows and Linux.  The value at system-type
will determine which discovery provider is loaded.  A value of gnu/linux
will load user-directories-linux.el and a value of windows-nt will load
user-directories-windows-nt.el.

  If one wants to add a file named user-directories-darwin.el or
user-directories-kfreebsd.el, patterned after user-directories-linux.el
or user-directories-windows-nt.el, then the directories for the two
systems would be correctly discovered.  As a cavaet emptor, I haven't
tested any windows-nt discovery, since I do not use Emacs on Windows. 
If the value system-type has no file to provide discoveries, all the
:data, :cache, :runtime and :config directories will be created, but
this time inside user-emacs-directory.

  I have assigned the copyright to the Free Software Foundation.

* WHAT CAN STILL BE DONE?

  - user-directories/user-directories-darwin.el;

  - user-directories/user-directories-kfreebsd.el;

  - improve setup-user-directories-default, if the layout specified at
that function is not sensible

  - make user-init-file writable during initialisation --- while one
loads the XDG file, and tries to set user-init-file at
user-directories-init.el, the value reverts to ~/.emacs for no reason. 
Help needed here.


  Thanks for your time.

    Best wishes,

      Francisco Colaço

 


[-- Attachment #2: user-directories.tar.bz2 --]
[-- Type: application/x-bzip, Size: 5883 bytes --]

[-- Attachment #3: 0xDB83911F.asc --]
[-- Type: application/pgp-keys, Size: 12199 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-05-12 15:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-06 19:04 Inclusion of XDG Base Directory library Francisco Miguel Colaço
2018-05-07  8:26 ` Francisco Miguel Colaço
2018-05-07 16:43   ` Stefan Monnier
2018-05-11 12:26   ` Eli Zaretskii
2018-05-11 20:22     ` Francisco Miguel Colaço
2018-05-12  6:52       ` Eli Zaretskii
2018-05-12  9:01         ` Francisco Miguel Colaço
2018-05-12 15:32       ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).