You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am a doom emacs user, setting up a new PC. Doom has moved to using XDG-compatible locations its default configuration source, which means keeping all configuration data in XDG_CONFIG_HOME/emacs. So, after I had my emacs configuration all nicely reproduced and tuned up, with the config loading from XDG_CONFIG_HOME/emacs, I moved on to setting up my ocaml dev env. Running user-setup install created ~/.emacs and ~/.emacs.d/opam-user-setup.el, and I thought nothing of it.
Problem
The next time I restarted emacs, I was suddenly back into the default emacs configuration.
As per the docs, this is because the ~/.emacs.d configuration location overrides the XDG-compatible location:
Emacs can also look in an XDG-compatible location for init.el, the default is the directory ~/.config/emacs. This can be overridden by setting XDG_CONFIG_HOME in your environment, its value replaces ~/.config in the name of the default XDG init file. However ~/.emacs.d, ~/.emacs, and ~/.emacs.el are always preferred if they exist, which means that you must delete or rename them in order to use the XDG location.
From the end users perspective, it looks like opam setup has hijacked the emacs configuration! This is easy to diagnose and fix if you happen to know the minutia, but could easily open up a rabbit hole hiding a red herring.
Suggested solution
The ideal behavior, I think, would be to search for existing emacs configuration data starting from the most marginal location (meaning, the one which is most easily overridden), which would mean first checking whether an existing config is located in the XDG-compatible location, and deferring to that location if found.
A complication to consider: a user could have ended up in a situation where they are actually using config data located in ~/.emacs.d, masking an old, unused XDG_CONFIG_HOME/emacs. In this case it would be helpful to alert the user of the conflict.
When in doubt, it would be better if opam prompted for input from the user rather than making a change that can override existing configurations.
Background
I am a doom emacs user, setting up a new PC. Doom has moved to using XDG-compatible locations its default configuration source, which means keeping all configuration data in
XDG_CONFIG_HOME/emacs
. So, after I had my emacs configuration all nicely reproduced and tuned up, with the config loading fromXDG_CONFIG_HOME/emacs
, I moved on to setting up my ocaml dev env. Runninguser-setup install
created~/.emacs
and~/.emacs.d/opam-user-setup.el
, and I thought nothing of it.Problem
The next time I restarted emacs, I was suddenly back into the default emacs configuration.
As per the docs, this is because the
~/.emacs.d
configuration location overrides the XDG-compatible location:From the end users perspective, it looks like opam setup has hijacked the emacs configuration! This is easy to diagnose and fix if you happen to know the minutia, but could easily open up a rabbit hole hiding a red herring.
Suggested solution
The ideal behavior, I think, would be to search for existing emacs configuration data starting from the most marginal location (meaning, the one which is most easily overridden), which would mean first checking whether an existing config is located in the XDG-compatible location, and deferring to that location if found.
A complication to consider: a user could have ended up in a situation where they are actually using config data located in
~/.emacs.d
, masking an old, unusedXDG_CONFIG_HOME/emacs
. In this case it would be helpful to alert the user of the conflict.When in doubt, it would be better if opam prompted for input from the user rather than making a change that can override existing configurations.
opam config report
The text was updated successfully, but these errors were encountered: