Friends,
I have written several years ago a package called xdg-paths.el. I have rewritten it as xdg-directories.el.
* WHAT IS xdg-directories.el
xdg-directories.el allows the package writers to locate a file in
Emacs user directories for different domains: data, configuration,
cache and runtime. It also locates files in the domains defined by the
utility xdg-user-dir, which is executed when finding the domain.
Using this package, an emacs-lisp package writer can put different
files under different directories, according to the domain thereof. A
cache file, which is normally not wanted in backups, can be named
under ~/.cache/emacs/<filename>, whereas a configuration file would be
under a different directory, in ~/.config/emacs/. Passwords and
security sensible files can also made to be in a directory where, as
the user logs out, is normally erased.
* BRIEF USAGE (see README.md at the Github repository)
Files form several domains can be located. Located means here, at the
lack of a better term, named, since the file name will be returned,
regardless of the file existence.
- User documents:
> (locate-user-document-file "org/agenda.txt")
> "/home/francisco.colaco/Documentos/org/agenda.txt"
- Configuration files:
> (locate-user-emacs-config-file "init.el")
> "/home/francisco.colaco/.config/emacs/emacs/init.el"
- Data files:
> (locate-user-emacs-data-file "recentf")
> "/home/francisco.colaco/.local/share/emacs/emacs/recentf"
- Cache files:
> (locate-user-emacs-cache-file "elfeed/index")
> "/home/francisco.colaco/.cache/emacs/emacs/elfeed/index"
- Runtime files:
> (locate-user-emacs-runtime-file "credentials.txt")
> "/run/user/1000/emacs/emacs/credentials.txt"
For example, init.el could be marked as a configuration file (and reside under ~/.config/emacs) and recentf as data file (being under ~/.local/share/emacs).