Friday, December 15, 2023

Emacs: Hidden Holiday Gems

Emacs HHG: Hidden Holiday Gems

1. Overview

The acronym HHG evokes Douglas Adams' Hitch Hikers Guide To The Galaxy in the minds of most geeks. This article takes a quick semi-guided tour through some of the gems that are hidden in plain sight within Emacs. This article was prompted by some recent discussions on the emacs-devel@gnu.org list which revealed the somewhat obvious — not everyone uses all available features in Emacs — if that were even possible.

So without further ado, here is a brie list of hidden gems in Emacs as a teaser — I use many of these on a regular basis, but as you'll see there are gems that I know of that I haven't managed to integrate into my workflow, leave alone those gems that I am not even aware of.

2. Emacs: Hidden Holiday Gems

Selective Display
Collapse/Expand content based on indentation. Useful in browsing code, as well as structured output from various shell commands.
Registers
Quickly save text fragments, buffer locations and window configurations and restore them easily. I use registers for saving text fragments, but have never used it as a means to navigate.
Bookmarks
Persist various types of locations. Note that registers can be persisted across Emacs sessions as well.
Tabulated Lists
Build up tabulated UIs that behave consistently.
Forms Mode
Leverage underlying syntax e.g., field-delimiters, to enable structured editing via a forms-like interface.
Mark Ring
Local and Global mark rings. This is one I've been aware of for over 30 years but never managed to work into my work-flow.
Undo
Both basic and advanced. I myself only use the most basic form of undo.
Dired
Surprisingly not everyone appears to use dired, or at least as heavily as I expected.
Writeable Dired
This became part of Emacs more than a decade ago — but often remains undiscovered and under-exploited. Ignorance leads to more complex and error-prone shell hacks.
Org-Mode
Org is often cited as one of the most powerful Emacs add-ons that makes Emacs attractive to engineers and authors alike. But the breadth and scope of this package means that not all of us use all of it. As an example, I use org-mode for all my writing, but have never used it for todo-list or agenda management.
Magit
Another magical gem that I use heavily — but there are more parts of Magit that I dont use than I use — not due to any shortcoming in Magit, but more because of the nature of my typical work-flow vs the myriad work-flows that Git provides and that Magit makes accessible to the mere mortal.
Forge
Interact with Git repositories — a powerful tool where I myself have only scratched the surface.
EWW
Hard to believe that shr and eww have now been part of Emacs for nearly a decade. Though not hidden, they still get ignored by most users because of the addiction to the JS-powered Web; EWW does not implement Javascript. But that shortcoming is a major win, both for efficiency and for preserving privacy — EWW remains one of the most effective means of focusing on the real content of Web pages.
Elfeed
With EWW for surfacing the content in noisy News pages, Elfeed provides the complementary functionality of browsing RSS and Atom Feeds — which together let you focus on content as opposed to endlessly mnavigating a Web site.
GNUS
Gnus remains one of the most powerful email tools, but its potential as an email-reader often gets overlooked.
Tramp
When I first discovered Emacs in Grad School, ange-ftp for opening files on a remote site was an incredible innovation. As the Web took over and FTP disappeared, the ability to open remote files from within Emacs receded into the background — but that functionality quietly turned into something more powerful, namely tramp. I myself mostly ignored Tramp until I discovered about 20 years ago that it was a neat way to edit files as Root on my laptop; but Tramp really came back into its own when I started working from home during the pandemic.
Eshell
A Shell that is deeply integrated into Emacs. I believe I would be more productive if I used Eshell all the time, but despite myself, I'm still using Bash in Emacs shell-mode!
Comint
A Command Interpreter to bind them all! This is a hidden gem that is a true work-horse when it comes to all Emacs functionality for interacting with command interpreters. It is a good example of a mature platform-level affordance, where Emacs is the platform.
Zip Archives
Emacs can open archive files like zip,

tar.gz and friends and provide an interactive dired-like interface. It also turns out to be a light-weight way of excavating XML content from MSFT word-processor files (DocX).

Calculators
Yes, there is more than 1;-) The built-in not-so-light-weight calculator and the even more powerful (and also bundled ) calc package. I still remember the time I was buying my first home 25+ years ago, and sitting with my real-estate agent while she educated me on mortgages. She was looking over my shoulder as I typed in Emacs; what to her looked like plain text, and what to me was my Scratch Buffer. After we had considered some options, I typed a few keys to invoke Calc in embedded-mode and a second later she was looking at that plain-text display showing the monthly installment for the mortgage we were discussing!

3. Conclusion

  1. There are clearly a lot more hidden gems than enumerated here; otherwise they wouldn't be Hidden.
  2. These work best when Emacs provides a cleanly defined platform that enables the creation of these extensions via Emacs Lisp.
  3. There is an interesting balance between letting a thousand flowers bloom vs refactoring to create common APIs based on developer needs. Org is an outstanding example of this, both with respect to enabling the discovery of such APIs, and an example of where a good set of platform-level APIs are rich for plucking; failure to do so means that at present, org-mode is turning into a platform in its own right atop the Emacs platform.

vHappy Holidays — And Share And Enjoy!