Emacs 28.1

By default folder .emacs.d location on my home folder. Smt like this:


But I need to change to another location to e.g:


Is it possible?

  • Use a symlink, or redefine HOME?
    – mikado
    Aug 17, 2022 at 12:48
  • Check github.com/plexus/chemacs
    – Rusi
    Aug 17, 2022 at 13:46
  • I'm betting this is a duplicate question...
    – Drew
    Aug 17, 2022 at 15:33

1 Answer 1


This is documented extensively in chapter 49.4.4 How Emacs Finds Your Init File. Always check the manual first.

Quoting the most relevant paragraphs:

Emacs looks for your init file using the filenames ~/.emacs.el, ~/.emacs, or ~/.emacs.d/init.el in that order; you can choose to use any one of these names. (Note that only the locations directly in your home directory have a leading dot in the location’s basename.)

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.

So there you have it; just set XDG_CONFIG_HOME to /home/alexeij/dev whenever you run Emacs.

  • 2
    Be careful about leaving ~/.emacs or ~/.emacs.d/init.el around: there is a search order and emacs stops when it finds the first one in the search list.
    – NickD
    Aug 17, 2022 at 13:32
  • The phrasing of the documentation is confusing. "[C]an also" implies that the behavior is not the default but it is. Oct 27, 2023 at 18:23
  • No, it’s not confusing. If XDG_CONFIG_HOME has no value then Emacs doesn’t use it. Your distribution may automatically give it a value, but that too is something you control.
    – db48x
    Oct 28, 2023 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.