Journal

2019-11-04 Starting Emacs with custom configuration directory

The usual thing people are told to do when debugging/isolating Emacs problems is to say emacs -Q, that is, start Emacs without reading in any configuration. Sometimes, however, this may not be a good idea. When there is some problem with packages, however, we may actually want to load some things, like a minimal set of packages if we suspect they do not work together. Of course, what we don’t want is changing our configuration.

Strangely enough, Emacs has a lot of options to suppress loading some parts of its default config (-q and -Q are the most well-known), but I couldn’t find any option to allow for a different location of its config files. That is not really a problem, however, since the place it looks for the configs is well-defined in relation to the user’s home directory. This means that it is enough to say e.g. HOME=/tmp emacs (assuming Bash at least, which is what everyone is using anyway, right? ;-) ), and we can install whatever package(s) we want, customize variables etc. – everything will go to /tmp/.emacs, /tmp/.emacs.d etc. What’s even better, we do not lose all of this configuration after restarting Emacs in the same way (of course, on systems where /tmp is cleared on reboot, this is not as persistent as it could be, but we can use anything instead of /tmp).

This may be quite useful not only for debugging problems with packages (right now I have some troubles with js2-mode, for instance, and the above technique seems to confirm that it is my config and not js2-mode which is to blame…), but also for demoing stuff. I hope to give some talk with slides shown from within Emacs in some time, and I do not necessarily want to use my normal config for that – if only because the modeline shows the minor modes I have turned on, and it might introduce a lot of noise for the audience.

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

More...