Hacker News new | past | comments | ask | show | jobs | submit login

I've never seen .emacs anywhere other than $HOME/.emacs, or seen Emacs write files outside $HOME/.emacs.d. In what situation does Emacs use $HOME/.config/?



Since Emacs 27.1, if $XDG_CONFIG_HOME/emacs/ exists and neither ~/.emacs nor ~/.emacs.d/ exist, then it will set user-emacs-directory to $XDG_CONFIG_HOME/emacs/ instead of ~/.emacs.d/.


So, if I understand correctly (and this would match my experience), if I compile emacs from sources on a new computer and just run make install, the "legacy" paths will be used instead of the XDG ones, unless I explicitly mkdir $XDG_CONFIG_HOME/emacs.

I would then say emacs supports XDG, but doesn't use it by default, right?


That's correct.


If you already have legacy paths, then Emacs doesn't migrate things for you, as far as I understand.

This is fair behaviour IMO, because migrating configs automatically might break user setups.


Based on the other comments, it sounds more like emacs supports XDG if you want it to, but still defaults to ~/.emacs if you don't explicitly set up an XDG environment for it. Distributions may choose to do so, but I don't think compiling from source does.


Then you have to support both forever. Its not clear why that is better.


When you create $XDG_CONFIG_HOME/emacs/init.el before starting emacs for the first time your `user-emacs-directory' will be set to it. However, the other locations (.emacs, .emacs.d) are always preferred if they exist.

Refer to section 50.4.4 (How Emacs Finds Your Init File) of the manual for more information.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: