Even More Batteries Included with Emacs | Karthinks
Home
About
Misc
Coding
Previous post<br>Next post<br>Back to top<br>Share post
Emacs features have a discoverability problem, and we’re chipping away at it one<br>demo at a time. The years since I wrote the last one of these have yielded more<br>surprising and useful finds, so it’s time again for a “batteries included”<br>report.
Note
This is the third in a series of articles highlighting useful but lesser-known<br>features included in Emacs.
Parts 1 & 2:
Batteries included with Emacs
More batteries included with emacs
“Lesser-known” is a subjective judgment. Roughly, it means that at the time of<br>writing, I have seen these features mentioned fewer than five times – and often<br>never – in the past two decades of dipping in and out of online Emacs<br>discourse. Some of the features covered in past entries are well known and<br>often recommended today. I claim no credit.
If you’re a new Emacs user, don’t start here. This is not a getting-started<br>guide. You will be better served by grokking basic Emacs concepts and sticking<br>to the most widely recommended packages. Once you’ve experienced the Emacs<br>equivalents of thoughts like “Why didn’t anyone think to put wheels on luggage<br>until 1990?”, this series might be more helpful.
My rule of thumb is that if you aren’t yet aware of undo-in-region, there is<br>much low hanging fruit for the picking, and you can come back to this article<br>after that supply has run out!
Veteran Emacs users tend to use some relatively niche Emacs features, but in my<br>experience it’s always a different subset for each user. So if you’ve been<br>around the block a few times, I promise there will still be surprises below for<br>you as well!
Same rules as before:
No packages, stock Emacs only
No steep learning curves. Learn each feature in under five minutes or bust .
No gimmicks . No doctor, tetris, snake, dunnet, zone,<br>butterfly… yes, we know about dissociated-press. Let’s move on.
Just the deltas . No commonly mentioned packages like Flymake, doc-view,<br>outline-minor-mode, gnus or eww. Nothing that Emacs brings up automatically or<br>a nonspecific Google search gets you.
Assume a modern Emacs, 28.1+.
Also, if you’re new to Emacs and still reading:
Emacs jargon<br>Modern parlance
M-x<br>Alt + x
C-x<br>Ctrl + x
Frame<br>Emacs window
Window<br>split/pane
Buffer<br>Contiguous chunk of text/data
Point<br>Cursor position in buffer
Active Region<br>Text selection
Region<br>Text selection (not highlighted)
Face<br>Font, color and display properties
I’m Sorry.
Okay? Let’s go:
Dictionary on hover (M-x dictionary-tooltip-mode)
Turn on dictionary-tooltip-mode to see word meanings in tooltips when you<br>hover over them:
Of course, tooltip-mode will need to be enabled as well, but that’s the<br>default.
If you have local dictionaries set up, it will try those first. Note that<br>Emacs’ dictionary can look up contemporary jargon and lingo too, usually via<br>Wiktionary:
[VIDEO: Emacs dictionary-tooltip-mode demo]<br>find-file and dired with wildcards
A surprisingly little known utility of two of the most used Emacs commands: you<br>can use wildcards when using both find-file and dired interactively.
When finding files with find-file (C-x C-f), open multiple files at once<br>with a wildcard like *foo*.txt.
When opening a directory with Dired, produce a custom listing of specific<br>files by specifying a filename wildcard.
Here’s a demo where both features are used to clean up some (very) old TeX<br>compilation artifacts and then open a bunch of LaTeX files at once:
[VIDEO: Emacs Dired and Find-File wildcards demo]
Play by play
Run Dired with a “two-level” wildcard */*_region_*: look for all files with<br>"_region_" in their name, but only in sub-directories.
Dired produces a listing of these files. (These are temporary files created by<br>AucTeX.)
Select them all (with dired-toggle-marks, bound to t) and delete them.
Run find-file with a wildcard, opening all TeX files in sub-directories.
Check the list of buffers to see that several TeX files have been opened.
(The command used to see the list of open buffers is consult-buffer, and the<br>completions are displayed by Corfu.)
The fact that this is possible when calling them programmatically is evident<br>from their function signatures. But realizing that this capability is also<br>available during interactive use requires reading through the full docstring,<br>and no one has the time for that!
In practice the Dired wildcard capability is superseded by a modern workflow<br>like consult-find exported as a Dired buffer by embark-export, but this<br>works out of the box.
List all URIs with M-x ffap-menu
You might be familiar with Emacs’ “find-file-at-point” feature, M-x ffap, that<br>checks if the cursor is on a valid file path and offers to open it.
This is accompanied by ffap-menu, a less well known but equally...