Back to Doom Emacs

· emacs · geekery ·

The inevitable wheel of Emacs life has circled back again, and — as the title suggests — I have moved back to Doom Emacs. When I last wrote about my Emacs configuration, I was trying to move away from frameworks (including Doom), and to set up my own configuration from scratch. It was a really fun process, and I think a necessary one for me to really understand how to configure and use Emacs, and the way that all the moving parts fitted together. However, I have recently overhauled my whole command line setup (again… more on this later), so I got curious to try out Doom again. It was always a great project, but in the time since I last used it Henrik Lissner has polished and improved it even more to the point where it is a really fast, slick and easy to use framework.

As I freely admitted when I wrote about moving to my own configuration, I didn’t really understand enough about configuring Emacs to be able to tweak a framework like Doom (or Spacemacs for that matter) to my liking. That has all changed now that I have much more experience, so I found it relatively easy to move my configuration over to Doom. Tweaking my own configuration from scratch has also enabled me to work out which packages are essential to me, and which I can manage without, so I could be more selective when setting up which packages I enabled and avoid getting overwhelmed.

If you use Doom, I recommend checking out the develop branch to get the latest changes, as this is the branch with all the active development. The wiki recommends the following to get started:

git clone -b develop ~/.emacs.d
~/.emacs.d/bin/doom quickstart

This command installs the core Doom files in ~/.emacs.d (obviously back up your old config and move it elsewhere first), and creates your personal configuration files in ~/.doom.d/. The main file in this directory is init.el which has a list of ‘features’ you can enable or disable. Each feature is a group of related bits of configuration (such as everything you need to code in Ruby, for example), and you just comment or uncomment lines to load what you want.

The quickstart script also places a couple of other skeleton files in your personal configuration: packages.el and config.el. I had to take a look at other people’s Doom configurations to see the best way to use these, but packages.el is where you instruct Doom to install additional packages using the (package! foo) notation. Comments at the top of the file show you how to use it to install packages from Github if they are not available on any of the Emacs package repositories, or to disable any of the built in packages so that you can override them. You don’t do any configuration of the packages here, but in config.el. Since I had been using use-package extensively in my own configuration, it was much more obvious to me how to set up the configuration in this file, and I could mostly just copy across bits of my old init.el file, and it all worked beautifully. You can split up your personal config into separate files and load those at the top of config.el if you want, and you can even write the configuration in an *.org file and tangle it, literate style, into lisp config files if you want. When you change your configuration, you use the doom script to refresh the setup (doom refresh), restart Emacs and your changes are loaded. Similar scripts enable you to update packages (doom update) or upgrade Doom itself (doom upgrade), and so far this has all worked pretty smoothly for me.

What I liked about Doom this time around is that it already included many of the features I configured myself when I was working from scratch, but in a much better-integrated way. This meant that I actually only needed to add and configure six additional packages to get things working the way I wanted. Doom does some very clever things with compilation (which I don’t understand), so that Emacs starts up extremely speedily (around 2 seconds for me on a relatively slow machine, a bit less on a faster one).

When you use the quickstart script, Doom asks if you want to use evil (i.e. vim) keybindings or Emacs native ones. When I configured from scratch, I used native Emacs keybindings, got comfortable with them, and even came to enjoy them. Indeed, I found myself using Emacs bindings on the few occasions when I opened vim or neovim, and wondered why n just resulted in a beep. However, I still craved modal editing, which is why I installed and used Clemens Radermacher’s innovative objed package. However, when I responded to the dialog in the quickstart script, I chose evil bindings before I knew what I was doing. It has felt like coming home again. I can enjoy and see the rationale behind Emacs keybindings, but I feel so much more comfortable with vim bindings.

I have been using vim for longer, which probably helps, but it’s not just that. Physically, I still find it easier to type the modal commands which are mostly located on the home row, and don’t require too many digital contortions to hit combinations of keys. I also find it easier cognitively to remember the bindings because they combine together logically. Once you know the commands to move by different syntactical units, you can combine those with numbers to delete one line or 10, and once you know the ‘verbs’, you can delete, copy, paste, or change the case of any number of different syntactical units. Basically, the vocabulary is small and easily learned, but can be combined to accomplish a wide variety of different effects. I this point I think I should just accept that I’m going to have :wq engraved on my headstone and leave it at that. When I last used evil bindings in Emacs, I occasionally bumped up against things not working quite how I would expect, but either I have been lucky this time, or Henrik has done a fabulous job in smoothing these inconsistencies out, because this time everything has felt beautifully seamless.

So, for now at least, I am really happy with my Emacs setup, and feel as if this is maintainable in the long term. I probably should have learned Emacs from scratch at the start, but where’s the fun in doing things the sensible way?