An obscure emacs package: elastic indent mode

29 Sep 2025

This post is written as a part of the emacs carnival, a monthly event where people write posts on a shared topic. This month the carnival is hosted by Rodion Goritskov and the theme is obscure packages.

For a very long time, i have been using a proportional font to write code. I think i started when i was messing around with the configuration options in python’s idle text editor, and i set the font to comic sans. And what do you know, the code was a lot more fun all of a sudden.

These days, i switch between a few different fonts, but usually i use noto sans or noto serif. I still often see code written in a monospaced font, and it’s fine, but it’s not as nice as reading code written in a nice, proportional font. For me.

One of the biggest issues with this kind of setup is that of indentation. A space character in a monospaced font is the same width as any other character, so it’s easy to see big leaps inward using whitespace. But the space character in any self-respecting proportional font is a tiny sliver. The intimacy this provides to word spacing is one of the big reasons for my preference, but it isn’t so pleasant for a character doing double-duty as indentation.

That’s where my favourite obscure package comes in. It’s elastic-indent-mode, a minor mode that comes as part of Jean-Philippe Bernardy’s elastic modes, a small package that tries to implement elastic tabstops in emacs. Elastic-indent-mode makes leading spaces the same width as the character directly above them.

It’s really simple, and honestly in practice it can be a bit janky. But for the most part, it allows me to write lisp code or html or rust, and have things lined up like anyone else using a monospaced font would expect. It’s particularly useful for lisp code, where without using it, the code feels very squashed and nothing lines up the way i want it to. But it’s not only beneficial there.

Programming languages often seem to have been designed under the assumption that the programmer will be reading and writing code using a monospaced font. Historically that made sense, and for various reasons that assumption is still the overwhelming practice today. Lots of languages feature little bits of cute syntactic sugar that assume that characters are equal little rectangles on a grid, and make semantic ascii art across lines. This all falls apart when the rectangles are not gridlocked.

Elastic-indent-mode brings back that grid where it matters, and lets me keep avoiding it where it doesn’t. It’s one of the many tiny reasons i keep using emacs. I don’t know of any other environment that provides something like this.

And if the idea of using a proportional font to write code repulses you, give it a try. Maybe something so trivial shouldn’t evoke such visceral reaction in the first place. But if you don’t like it, you can go back to a monospaced font easily. If you do, well, welcome to the future.

emacs