Although I use Emacs for my day-to-day editing tasks, I haven’t gotten around to updating a lot of my config, some of which dates back to around 2004 when I started using Emacs. There’s a lot of cruft in my .emacs, particularly in some of the settings I’ve put in via customize. So, this week, I decided to clean things up a bit and try out new stuff. I decided to drop a lot of my existing config, reconfiguring stuff as I went along.

In the process of cleaning things up, I’ve also decided to try out new ways of doing things in Emacs, in particular with the how to navigate around buffers and files. Early on, I picked up ibuffer as my go-to way for selecting and managing my buffers instead of the default buffer menu. That was then replaced with ido later on (for reasons that escape me now 1).

However, I’ve previously been dipping my toes with Helm. I wasn’t really using Helm fully, just bits and pieces – in particular, I was using a minimal config of helm-projectile. (I also forgot what else other bits and pieces I was trying out that depended on Helm). In any case, this week I’m plunging into getting Helm everywhere, using Helm to replace a bunch of things in the system for instance. It’s been wild, and I although I stumble here and there, I think I just might keep Helm.

Admittedly, diving into the deep end this way has its downsides. Thankfully, I’m on a break between jobs, so I can afford to stumble through my Emacs usage a little bit.

If you want to take my Emacs config up for a spin, clone it from my Git repo here, and add a .emacs.el in your home directory with a single line:

    (load-file "~/.emacs.init/main.el")

replacing ~/.emacs.init/ with the path to your own clone of my repo.

Keybindings, Meet Muscle Memory

One of the things that is working against me though is my own damned muscle memory: years of hitting C-x C-f2 and then expecting Tab to do completion has often gotten me flatfooted with Helm replacing find-file, for one. Hitting C-x b has some similar weirdness for me, with Tab not completing but instead listing Helm’s alternate actions for the particular selected item. Nevertheless, it’s been pretty fruitful to use Helm so far for those particular tasks.

Some keybindings though I expect to exist, after a few years of using them to get around, so I’ve added them in.

For instance, a colleague of mine introduced me to PeepOpen, which he was using to navigate between files in MacVim. By default, PeepOpen uses S-t (Super-t, which on macOS is ⌘-t), and I’ve been using that ever since, even when I stopped using PeepOpen and started with other alternatives such as Projectile. So, I needed to bind S-t to something, or else I would go nuts.

Outside of Helm, I’ve also gotten used to moving between buffers using the arrow keys (using windmove). Previously, I’ve been using windmove-default-keybindings to use the default “shift and arrow key” bindings, but I’ve tweaked that in my new config, binding instead to S-s-right for instance: I’ve added the Super prefix key to all of the bindings, but I might relent later on and go back to the defaults; we’ll see.

I also pulled in a lot of my keybindings from my old config, although that I’ll probably clean that up, seeing as there’s a bunch of config I don’t already use nor need. I previously set up F8 as a general “these are my shortcuts” key, so for instance hitting F8 m would open Gnus for my mail. A lot of that stuff I no longer use, so I’ll probably discard it, although I’ll still keep F8 as a prefix key.

I also used to use bookmark.el heavily: I’ll see if I can integrate that with this new Helm world.

Creature Comforts

I mentioned PeepOpen. As I said, I’ve gotten used to a lot of the affordances that PeepOpen gave, in the brief time of my using it. In particular, I liked how it does fuzzy matching, instead of just doing prefix or substring matching; I use that completion model quite heavily as well outside of Emacs, in particular within Alfred.

So, I’ve set helm-mode-fuzzy-match to t, which reflects how I expect it to work, and makes things consistent with Alfred.

I’ve also set Helm to use the same window3 as the buffer I’ve invoked it in, by setting helm-split-window-default-side to 'same. The default is just too confusing to me: seeing Helm do a frame split only sometimes confuses me as to where I should look. With this, I know exactly where Helm shows up.

Outside of Helm, I have only quite a few changes to my config overall. I want to keep things working as close to how I’m used to, where it makes sense. I’ve kept Solarized Dark as my Emacs theme of choice, as well as the use of powerline (particularly spaceline) for my modeline. I’ve also kept the use of buffer boundaries in the fringe, as I often want to see if I’ve inadvertently added unneeded blank lines to the end of a file I’m working on. Hack is still my font of choice, of course.

Meta: Organizing My Emacs Config

Back around 2007 when I started to keep my config in version control, I had decided on splitting out my then-monolithic .emacs into separate files, one per package or module or what-not. Each elisp file in my config directory with the suffix .init.el would be loaded by a little bit of code, so all I needed to do to add a new bit of config or functionality was to add that a file in my config directory; similarly, I could disable stuff by removing the relevant .init.el file, or renaming it .noinit.el.

That worked for a while, but I realized that it’s become quite unwieldly as well, seeing as I ended up just using customize a lot, and having a lot of little files just becomes confusing.

Also: my original intent was to perform module configuration and loading in those little files. This was important pre-Emacs 24 and ELPA, when you had to download elisp packages and manually load them into your Emacs. Emacs 24 and ELPA just made a lot of those things unnecessary, so I decided to just refactor everything.

Now, instead of keeping files per module, I’ve reorganized things according to function. I have an init file containing all my config for development, and a file containing all my navigation config (including my Helm config). Admittedly, disabling individual files no longer makes that much sense, seeing as, for instance, development.init.el contains all of my config for working on code, and disabling that would disable a large swathe of functionality; it still makes sense to at least separate everything out this way though, a little happy middle between lots of small files and a single monolithic config.

Speaking of packaging though, I also picked up the use of John Wiegly’s use-package a couple of years back, and it’s helped with keeping package-related config together quite nicely. I’ve also started to use a little more of its functionality (:bind is a bit of a TIL).

Previously, most of my Emacs usage has solely been on Linux machines, and there was a bunch of things that I hard-coded into my config – tool paths for one. I’ve now added a bit of code so that I load platform-specific stuff separately, so that way I can use my config on my Macbook Pro as well as some Linux VM desktops I still have.

Acclimatizing To Everything

So far, it’s been pretty spectacular, even with the bumps caused by my misfiring muscle memory. I’ve been enjoying tweaking things here and there, and learning a little more about the tool I use everyday. There’s a lot more I don’t know, or haven’t had the opportunity yet to try out, so it’s exciting to have the time to do it.

There are probably a few things I’ll tweak here and there, to get the most out of my config, and there’s definitely a bunch of things I haven’t gotten rid of (the old F8 keymap, for instance). But so far, I’ve been happy with the reconfig.

  1. Postscript, June 21– I looked at an older version of my config in my archive, and apparently I was mistaken: I used iswitchb not ibuffer – and I switched to ido because iswitchb was deprecated circa Emacs 24. 

  2. For those not using Emacs, or not well-versed with how Emacs represents keybindings: a lot of things in Emacs can be accessed from the keyboard with a sequence of keys. For example, C-x C-f is used to open a file, and represents hitting Ctrl with X, releasing, and then hitting Ctrl with F. Modifier keys are usually represented by uppercase letters, followed by a dash connecting it to the key it modifies: C- for Ctrl, and M- for Alt (otherwise known in Emacs as Meta). Shift is usually represented by the equivalent uppercase letter or shifted key (T instead t means to hit Shift and T), but sometimes as s-, when the key doesn’t have a shifted representation. Sometimes you’ll see something like C-M-x: that means hitting Ctrl, Alt, and X at the same time. You can find more about it in the Emacs manual here

  3. I use the naming conventions in Emacs for things like windows, frames, buffers, etc. It gets confusing if you’re not used to it, so my apologies. Check out the Emacs manual for more info though. 

Previously: Food