Emacs packages I like
published: 29 July 2024, tagged: Emacs
During the time I’ve been using Emacs, a handful of packages have stood out to me as being particularly useful, reliable, and generally enjoyable to use. A few of them in particular, I like enough to write about :)
Modus themes
One of the first things I see when I start a new Emacs session is my colour theme, so we may as well start there. My theme of choice has been one of Protesilaos Stavrou’s Modus themes for almost as long as I’ve been using Emacs, and I’ve yet to find anything else that shares Prot’s attention to detail. The themes are designed with accessible readability in mind, so the contrast between the background and foreground colours is always high. On top of that, variants of both the dark and light themes are included which are optimised for users with red-green or blue-yellow colour deficiency.
Colours alone don’t make an Emacs theme though, and it’s everything else about the Modus themes that really shines. The highlighting is well thought out, with colours being used only where they’re useful; the coverage of third-party packages is great; and there are a staggering number of customisation options. They’re an unapologetically usable set of themes, and I love them for it.
Vertico/orderless/marginalia
Lots of things in Emacs use the built-in completing-read
function to get user input while completing from a list of candidates. The default behaviour is to provide an input field with bash-like tab-completions, but sometimes it’s nicer to show the list of candidates on screen and filter it with a fuzzy finder. Daniel Mendler’s vertico, for ‘VERTical Interactive COmpletion’, adds the first of these features, orderless and adds the second. For example, enabling vertico-mode
will turn this:
Find file: ~/src/some-project/█
into this:
*/7 Find file: ~/src/some-project/█
Cargo.lock
Cargo.toml
LICENSE
README.md
src/
target/
.gitignore
where the list of files gets filtered down as you type. The benefit of vertico’s approach, using the completing-read
mechanism instead of redefining each function, is that is plays nicely with other parts of Emacs. For example, Omar Antolín Camarena’s orderless defines a completion style which tells Emacs how to filter and sort candidates, and vertico will use that ordering with no extra configuration. Orderless is a great companion to vertico, as it sorts completions based on how recently they were last used, and filters them fuzzily based on the input string (for example typing car lo
will match Cargo.lock
), making vertico act like the fuzzy finders in more modern editors. Marginalia, another of Daniel’s packages, improves vertico once again by showing extra details beside each candidate where possible: for example, showing file details in the file picker or function docstrings in M-x
. For very minimal setup, these three packages vastly improve the completion experience in Emacs.
project.el
and Magit
Emacs’ built-in project
package is a neat little feature that works right out of the box, but it’s far too useful not to mention here. It adds a handful of helpful functions for dealing with projects (which it automatically detects by looking for version controlled directories), of which I have a few favourites:
C-x p p
: switch to a different projectC-x p f
: find files in projectC-x p c
: runcompile
in the project rootC-x p g
: project-wide grepC-x p !
: execute a shell command from the project root
In particular, C-x p f
in combination with vertico is a great fuzzy file finder, similar to Quick Open in Visual Studio Code or fzf
/telescope in (neo)vim.
Complementing project
, Magit is one of the best Git frontends I’ve ever used anywhere, let alone for Emacs. As a testament to just how good it is, its developer, Jonas Bernoulli, started a Kickstarter campaign in 2017 asking for CHF 55 thousand to develop Magit full time for an entire year. He raised almost CHF 73 thousand. As a result, Magit is perhaps the most feature-complete Git frontend beside the Git command-line. It aims to look similar to the output of Git itself, but everything in a Magit buffer is actionable. You can stage and unstage files by pressing s
and u
in the status window, or rebase onto a particular commit by pressing r
with the cursor on that commit in the log. Even if you don’t use Emacs for anything else, I still think Magit is worth a try on its own.
Eglot
LSP is a relatively new addition to my setup compared to everything else here, since I was content with using keyword completion and tags for the features I needed – that is, until I tried rust-analyzer
, and now writing Rust doesn’t feel the same without it. In Emacs, lsp-mode
and eglot
seem to be the two most popular LSP implementations, the latter of which is included in Emacs 29 onwards. While lsp-mode
seems to be the more feature-rich of the two, eglot
takes an approach similar to Vertico of being minimal and building on core Emacs features wherever possible. As well as, in my opinion, feeling more responsive than lsp-mode
, it also means any configuration you may already have for flymake
or completion-at-point-functions
will work identically with LSP features. In particular, Corfu (once again from Daniel Mendler) works perfectly with eglot
out of the box. I really don’t have much else to say about eglot
; it just seems to work whenever needed, and stay out of the way when it isn’t.