Bozhidar Batsov over at Emacs Redux has a short post on the new(ish) Emacs command line option, init-dir
. It does just what it sounds like: it allows you to specify where to find the init.el
file and other configuration information. I remember seeing it in the release notes for Emacs 29 but didn’t think a whole lot about it.
Batsov, of course, zeroes in on an important use case: enabling you to try (or use) different configurations while keeping your main init.el
intact. He uses the example of having one init file for the Prelude distribution and another for Spacemacs.
Using the option for trying different distributions makes a lot of sense because the init files and required packages differ substantially. Even those of us who happily use vanilla Emacs will find it useful for trying out experimental configurations or for refactoring our configurations.
As Bastov remarks, you can do the same thing with symlinks and, indeed, that’s just what he and I used to do but using init-dir
makes things simpler and easier and is another way of sanding down your workflow. Where before I may have hesitated to go through all the steps to set up an alternative configuration, now it’s simply a matter of copying my init.el
, making the necessary edits, plopping it in some directory, and pointing Emacs at it with init-dir
.
It’s nice to see Batsov blogging more again. I almost always learn something new when he posts.