[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Inclusion of XDG Base Directory library

From: Francisco Miguel Colaço
Subject: Inclusion of XDG Base Directory library
Date: Sun, 6 May 2018 20:04:27 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0


  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
;;   (setq projectile-cache-file (locate-user-cache-file


  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.


  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

  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.


  - 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: user-directories.tar.bz2
Description: application/bzip

Attachment: 0xDB83911F.asc
Description: application/pgp-keys

reply via email to

[Prev in Thread] Current Thread [Next in Thread]