From: "Francisco Miguel Colaço" <francisco.colaco@gmail.com>
To: Emacs Devel Mailing List <emacs-devel@gnu.org>
Subject: Inclusion of XDG Base Directory library
Date: Sun, 6 May 2018 20:04:27 +0100 [thread overview]
Message-ID: <779935bf-79ea-5783-4c9c-4b7e2857bc50@gmail.com> (raw)
[-- 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 --]
next reply other threads:[~2018-05-06 19:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-06 19:04 Francisco Miguel Colaço [this message]
2018-05-07 8:26 ` Inclusion of XDG Base Directory library 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=779935bf-79ea-5783-4c9c-4b7e2857bc50@gmail.com \
--to=francisco.colaco@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.