I’ve mentioned before that Emacs configuration is a black hole that can easily swallow any spare cycles that wander into its event horizon. Part of that for me is reading how other people do it. Over at MetaSandwich, Selah has an interesting take on how to do it correctly. One of the things that makes it interesting for me is that he is one of the few people I’ve read who do essentially what I do.
He writes about what he considers the two main problems in Emacs configuration:
- How you should arrange the configuration file to make Emacs startup as fast as possible.
- Where should you put things.
Selah says he used to spend a lot of time worrying about how to minimize his startup time. Then one day he realized that, hey, it doesn’t really matter. It doesn’t matter because he, like most of us, doesn’t restart Emacs very often. He starts his once or twice a week; I keep mine going for weeks at a time. I usually start Emacs only at boot time and I reboot only for an OS upgrade or, in the case of my laptop, if I’m traveling. So startup time doesn’t matter very much. As Selah points out, even if it took 30 seconds that’s less than a minute a week (for him) and maybe 5 seconds for me.
As it turns out,
emacs-init-time tells me that my current startup time on my iMac is 4.8 seconds without me spending a single second trying to optimize it. Why should I worry about it? I feel confident that that’s true for most of us.
The second problem is a little more controversial. Most of the Emacs hackers that I respect tend to have a complicated configuration architecture with several files and even subdirectories. Look at Steve Purcell’s or Magnar Sveen’s configurations for examples of that strategy. I on the other hand keep pretty much everything in
init.el. Recently, I boldly struck out for uncharted territory and moved machine and platform specific configurations into their own small files that get loaded automatically based on the
system-type variables but mostly everything lives in a single file.
I’ve often felt like the Maytag repairman because of my preference for a single file but now Selah joins the party and makes a pretty good case for having a single file. He even gives a little code that arranges a handy index of your
init.el for use with
imenu. That’s nice but I don’t need even that. I pretty much know where things are in my
init.el and I have headers for the various sections so I can go right to them with incremental search.
In the end, of course, there’s no right or wrong way, just personal preferences. Still, I seem to be endlessly fascinated by how people do their configurations (and what’s in them, of course) so if you want to share your methods, leave a comment.