[Top][All Lists]

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

Re: user-directory: New library to find user {conf, data, state, ...} fi

From: Stefan Kangas
Subject: Re: user-directory: New library to find user {conf, data, state, ...} files
Date: Sun, 7 Nov 2021 21:04:42 -0600

Eli Zaretskii <eliz@gnu.org> writes:

>> Note that on GNU/Linux, even if the user has their configuration file in
>> "~/.emacs.d/", the library currently prefers the XDG paths here:
>>     (user-file 'cache "image-dired")
>>     => "~/.cache/emacs/image-dired"
> This contradicts how Emacs by default finds the init file: its
> preference is the other way around, and it sets user-emacs-directory
> according to the directory from which it loaded the init file.  I
> don't think I understand why this package should behave differently by
> default (it could do that as an opt-in option, of course, if that is
> considered useful to someone).

It should because it is a change for the better.  We have a chance to
decide what this should look like for the foreseeable future, and I
don't think we are bound by past decisions if they do not produce
optimal (or even good) results.

Here's my take on it:

The `user-emacs-directory' directory currently contains a grab-bag of,
well, everything, which among other things makes it hard for a user to
know what is safe to delete and what is not, which files you would need
to backup, etc.  You basically need to manually inspect the files and
consider their content one by one.

The big use-case here, though, is that we want to be able to easily
synchronize our Emacs configuration file between several machines.  You
don't want to synchronize things like your completion history or
recently opened files, because it is not very useful, and you will have
an infinite amounts of conflicts.  (It's somewhat easier with version
control, which is what I use, but less so if you want to use rsync or

The solution is to proscribe that:

The categories data, cache and state files belong in specific `data',
`state' and `cache' directories.  This means that e.g. my bookmarks file
goes to the data directory, the recentf and saveplace file goes to
`state', while my image-dired thumbnails go to `cache'.  As for runtime
files, I note that `server-socket-dir' already uses XDG_RUNTIME_DIR (but
gets it manually).

IOW, all this should be orthogonal to where your init file is placed.
You can put it in any of the accepted locations, including the XDG one
if you like.  (Personally, I keep mine in "~/.emacs.d/init.el" and will
continue to do so.)  You should still be able to get all of the above,
by default and with no hassle.

What I propose is obviously inspired by the XDG BDS, but with the Emacs
twist that its interface is not tied to that standard, it's completely
customizable, and it can easily grow to be platform independent.

With all that being said, we must take great care not to cause
unnecessary churn.  In particular, we should absolutely not break
anything that's currently working.  This means that we should respect
locations of already existing files, and ensure they continue working

PS. Note that (user-directory 'config) in particular already just falls
    back to use whatever `user-emacs-directory' was set to.  There is no
    need to duplicate what is happening in startup.el, or to try to
    outsmart it.

reply via email to

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