The basic idea
We all love XDG, and while ~/.config/doom
and ~/.config/emacs
are very nice, I can’t help but feel that shoving so much under ~/.config/emacs
is somewhat abusing the idea of a “configuration directory”.
I’d like to start a conversation about how things might be able to be shuffled around a bit to fit the spirit of the XDG directories more, as I think a change like this would fit well with the large shifts currently going on with Doom.
A recap of the XDG dirs
XDG_?_HOME |
Default | Purpose |
---|---|---|
DATA |
$HOME/.local/share |
User-specific data files |
CONFIG |
$HOME/.config |
User-specific configuration files |
STATE |
$HOME/.local/state |
State data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in $XDG_DATA_HOME
|
CACHE |
$HOME/.cache |
User-specific non-essential data files |
RUNTIME |
/run/user/$UID |
User-specific non-essential runtime files and other file objects (such as sockets, named pipes, …) |
$HOME/.local/bin |
User-specific executable files |
For windows and mac equivalents, see GitHub - OpenPeeDeeP/xdg: A cross platform package that follows the XDG Standard.
A tentative proposal
To kick things off, I’ve just taken a few of the dirs that Doom uses off the top of my head and posited where the most appropriate place for them to exist might be.
If there are any good suggestions, I’ll edit this listing to apply them.
Data
Basically the “important stuff”, so I’m thinking:
- Packages
- Documentation
- Doom module definitions (maybe?)
Config
Well, we already have ~/.config/doom
…
That said, profiles could go here.
State
A few things come to mind here, namely:
- Recent files
- Bookmarks
- Known projects
- Transient history
- Scratch content
- Forge info
- Various other history-type files
- Various log files
Cache
I take this as files that could be deleted where the user shouldn’t observe any different behaviour as a result.
For starters we have ~/.config/emacs/.local/cache/
, and everything contained therin.
Then there’s the ELPA/MELPA/etc. archives/caches.
In addition, I think the ~/.config/emacs/.local/env
file might go here, particularly if it could be automatically regenerated.
Lastly, if they’re (re)generated on-the-fly, then .elc
and .eln
files could potentially fit here, but nothing else comes to mind.
Runtime
The one thing that could fit here is the emacs-server files, currently in ~/.config/emacs/server/
.
Binary files
Currently we have ~/.config/emacs/bin/{doom,doom.cmd,doomscript,org-capture,org-tangle}
. Perhaps these could be symlinked into ~/.local/bin
?
What does that leave in ~/.config/emacs
?
I’d think just enough to set up load paths and kick things off. Possibly just early-init.el
?
I’d imagine that when doom install
is run, it would move the main repo into say $XDG_DATA_DIR/emacs/doom
, early on and then set up the rest and so allow everything other than the very first steps to assume the layout described above.
Actually implementing the restructuring
There are at least two ways we could go about this.
- Put everything in what we consider to be XDG-appropriate location, and have a helper script/function to do this reorganisation to the current layout
- Use the XDG-appropriate locations on new installs, and symlink to recreate the current layout