Why Emacs

Published on 2022-07-03 by Spencer Peters

Emacs looks like a normal text editor with some remarkable features, like highly configurable keyboard shortcuts. But Emacs is really just a couple of core abstractions running on top of a live Lisp interpreter. Every keystroke you enter is bound to a Lisp function, which is run in the interpreter. These functions act on buffers, which can display the text stored in a file, but can also display images, full-featured configuration menus, and more. An Emacs window can be tiled with many buffers that together display all the context needed for a programming/writing/research task. In a real sense, Emacs is more like an operating system that hosts buffers, than it is a program that edits text files. Hence the quote (Erwin, #emacs, Freenode): "I'm using Linux. A library that emacs uses to communicate with Intel hardware." (Writing this, I forgot the exact quote, so I opened a new vertical pane in my Emacs window, hit C-x C-b (list-buffers, C = CTRL), and typed "emacs". That narrowed the list to the pdf for the book "Mastering Emacs", where the quote headlines the intro. (Writing this, I forgot the name of list-buffers, so I entered C-h k C-x C-b, describe-key C-x C-b, to look it up.)

What is the upshot of this? Linux (or MacOS or whatever) is an operating system for your programs. Emacs is an operating system for YOU. My context (books and papers I'm reading, programs and papers I'm writing) is all instantly accessible using C-x C-b, and when I'm working, I can easily organize it on my screen. For me, context is the biggest benefit of using Emacs. But configurability, the other, more often celebrated (and mocked) feature of emacs, is needed to unlock the full benefits of context.

Because Emacs is a running Lisp interpreter, you can get it to interpret your keystrokes any way you want. It's easy to poke fun at the result. In practice, Emacs is designed to do this in a smart way, using prefixes like CTRL and META (for me, the option key) bound to Lisp functions that are globally indexed and documented within the editor. The default keyboard shortcuts are good, and they will make you more efficient at editing text over time. For a programmer (or even a writer), this is a big win. For the average user, it might not be worth the effort. But the key point is that configurability amplifies the ability of Emacs to maintain your context! A program can't maintain research context if it can't display pdfs and compile LaTeX code. Thanks to its configurable architecture, Emacs can do both of these things quite well (using pdf-tools and auctex). And, if you use Emacs for more things--reading, writing, programming, todo lists--the more familiar and effective you become with the keyboard shortcuts and basic use patterns. Just having a uniform interface for plaintext search is, somehow, incredibly valuable. I wish I could have my email and browser in Emacs. Currently, email is possible but challenging to configure, and full featured browsing seems impossible.

Using Emacs does require some configuration, and there is a learning curve. This is a real drawback. I've lost many painful hours wrestling with pdf-tools and auctex, and enjoyed many more lost work hours fiddling with my configuration and improving my workflow. Even now, I'm squarely an Emacs novice. But I'd rather be a novice in a deep field/tool that enables compounding growth in skills, than a master of a shallow, special-purpose field/tool. If you're keen to try Emacs, make sure that you are using the GUI/desktop version, not the terminal version. That way, you can use the mouse! I tried to pick up terminal Emacs before I knew what I was doing, and failed to get off the ground--the learning curve was too steep. I like the Castlemacs starter configuration for minimizing the learning required for Emacs to be usable.

I hope I've inspired you to think a bit more about Emacs, and tooling more generally. I think it's something that gets surprisingly little attention. (Even among computer scientists who find themselves doing mathematical work! They should know about the advantages of IDEs and tooling, but they typically work with pencil and paper and then "data entry" their work into LaTeX, a typesetting system that knows nothing about mathematical semantics. But that's another post!) If you end up trying it, drop me a comment (or email) and let me know how it goes.