<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss"
        xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
        xmlns:media="http://search.yahoo.com/mrss/"><channel>
<title>M-x apropos Emacs</title>
<atom:link href="http://www.matem.unam.mx/~omar/apropos-emacs.xml" rel="self" type="application/rss+xml" />
<link>http://www.matem.unam.mx/~omar</link>
<description><![CDATA[]]></description>
<language>en</language>
<pubDate>Fri, 12 Jun 2026 11:55:06 -0600</pubDate>
<lastBuildDate>Fri, 12 Jun 2026 11:55:06 -0600</lastBuildDate>
<generator>Emacs 31.0 Org-mode 9.8.5</generator>
<webMaster>omar@im.unam.mx (Omar Antolín Camarena)</webMaster>
<image>
<url>https://orgmode.org/img/org-mode-unicorn-logo.png</url>
<title>M-x apropos Emacs</title>
<link>http://www.matem.unam.mx/~omar</link>
</image>

<div id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#underappreciated-emacs-built-ins">Underappreciated Emacs built-ins</a></li>
<li><a href="#may-i-recommend-eww-for-emacs-innovative-ui">May I recommend eww for Emacs's innovative UI?</a></li>
<li><a href="#exploring-data-with-completion">Exploring large amounts of data with completion</a></li>
<li><a href="#vim-is-composable">Vim is composable</a></li>
<li><a href="#elevator-pitch">Elevator pitch</a></li>
<li><a href="#ten-things-to-try-with-embark">Ten things to try with Embark</a></li>
<li><a href="#writing-experience">Writing Experience</a></li>
<li><a href="#the-case-against-which-key-a-polemic">The case against which-key: a polemic</a></li>
<li><a href="#emacs-keymaps-can-have-prompts">Emacs keymaps can have helpful and even dynamic prompts</a></li>
<li><a href="#my-quest-for-completion">My quest for completion</a></li>
<li><a href="#welcome-to-M-x-apropos-Emacs">Welcome to <code>M-x apropos Emacs</code></a></li>
</ul>
</div>
</div>
<p>
<a href="https://www.matem.unam.mx/~omar/apropos-emacs.xml">RSS feed 🛜</a>
</p>
<item>
<title>Underappreciated Emacs built-ins</title>
<link>http://www.matem.unam.mx/~omar/apropos-emacs.html#underappreciated-emacs-built-ins</link>
<author>omar@im.unam.mx (Omar Antolín Camarena)</author>
<guid isPermaLink="false">http://www.matem.unam.mx/~omar/apropos-emacs.html#underappreciated-emacs-built-ins</guid>
<pubDate>Fri, 12 Jun 2026 11:52:00 -0600</pubDate>

<description><![CDATA[<p>
<i>Published: &lt;2026-06-12 Fri&gt;. Comments on <a href="https://mathstodon.xyz/@oantolin/116738407269360415">Mastodon</a>.</i>
</p>

<p>
This month's <a href="https://rossabaker.com/blog/underappreciated-emacs-built-ins/">Emacs Carnival</a>, hosted by Ross A. Baker, is about
underappreciated Emacs built-ins. Let's take commands: how do you know
if an Emacs command is underappreciated or not? If you read a lot of
Emacs discussion online and keep track of how much people mentioned
each command and what they said about it, you could use that data to
decide. But I don't keep track carefully of that, so as a quick proxy
I've decided to take as signal of lack of appreciation that Emacs does
not come with key bindings for the command. And as evidence for
<b>under</b>-appreciation I'll arbitrarily use the fact that <b>I</b> appreciate the
command enough to give it a key binding. I don't know if either of
these are great criteria, but I also think the stakes are pretty low
so it's OK if I'm wrong. 🙃
</p>

<p>
So here are, in no particular order, my top dozen Emacs text editing
commands that I bind to a key but come with no default key binding:
</p>

<ul class="org-ul">
<li><code>zap-up-to-char</code>: It kills text up to right <i>before</i> a given character.
I find it more useful than <code>zap-to-char</code> which kills up to and
<i>including</i> the character you type.</li>
<li><code>forward-to-word</code>: this moves you to the first character of the next
word (compare with the more famous <code>forward-word</code>, which leaves point
at the end of a word).</li>
<li><code>backward-to-word</code>: the backward-moving companion to the previous
command.</li>
<li><code>mark-beginning-of-buffer</code>: self-explanatory, set a mark at the
beginning of the buffer.</li>
<li><code>mark-end-of-buffer</code>: self-explanatory too.</li>
<li><code>copy-from-above-command</code>: I mostly use it without a numeric prefix
which causes it to copy the previous starting from the column you
are one.</li>
<li><code>duplicate-dwim</code>: a variant of the previous one, this copies the
<i>current</i> line one line below. I keep using both of these and thinking
I should settle on just one.</li>
<li><code>transpose-sentences</code>: insane this doesn't have a default binding.</li>
<li><code>transpose-paragraphs</code>:  same.</li>
<li><code>kill-paragraph</code>: same!</li>
<li><code>up-list</code>: love this command: it puts point after the current
s-expression, why does <code>backward-up-list</code> get a key binding and not
this one? I think I might even use it more than the backward one!</li>
<li><code>delete-forward-char</code>: OK, this one is truly bizarre! By default <code>C-d</code>
is bound to <code>delete-char</code> but its documentation explicitly says "The
command ‘ <code>delete-forward-char</code> ’ is preferable for interactive use ,
e.g. because it respects values of ‘ <code>delete-active-region</code> ’ and ‘
<code>overwrite-mode</code> ’." The documentation is right! Rebind <code>C-d</code>!</li>
</ul>
<div id="outline-container-org26989b8" class="outline-3">
<h3 id="org26989b8">Bonus underappreciated built-in: ecomplete</h3>
<div class="outline-text-3" id="text-org26989b8">
<p>
In case my criterion for underappreciatedness is wrong, I'll hedge my
bet by mentioning another Emacs built-in I anecdotally don't see
people use that much: the <code>ecomplete</code> package for email address
completion. Its simple, straightforward and works flawlessly. If you
want to store lots of other information about your contacts you'll
need a fancier package like <code>org-contacts</code>, <code>bbdb</code> or <code>ebdb</code>, but if you
just want to pair names with email addresses, <code>ecomplete</code> can do that
with zero fuss. All you need is:
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span style="color: #0031a9; font-weight: bold;">setq</span> message-mail-alias-type 'ecomplete
      message-self-insert-commands nil
      message-expand-name-standard-ui t)
</code></pre>
</div>
</div>
</div>
]]></description>
</item>
<item>
<title>May I recommend eww for Emacs's innovative UI?</title>
<link>http://www.matem.unam.mx/~omar/apropos-emacs.html#may-i-recommend-eww-for-emacs-innovative-ui</link>
<author>omar@im.unam.mx (Omar Antolín Camarena)</author>
<guid isPermaLink="false">http://www.matem.unam.mx/~omar/apropos-emacs.html#may-i-recommend-eww-for-emacs-innovative-ui</guid>
<pubDate>Sat, 16 May 2026 16:26:00 -0600</pubDate>

<description><![CDATA[<p>
<i>Published: [2026-05-16 Sat]. Comments on <a href="https://mathstodon.xyz/@oantolin/116586598571160370">Mastodon</a>.</i>
</p>

<p>
I think it's safe to say many people regard the Emacs Web Wowser
(henceforth <code>eww</code>) as a toy, not really usable as web browser. They'll
say "maybe for documentation" (meaning: to read documentation for some
piece of software). Of course, there is plenty of truth to this view:
<code>eww</code> cannot run JavaScript, so a lot of the modern web app cannot
possibly work. But I think <code>eww</code> is underrated and, for <a href="https://www.emacswiki.org/emacs/CarnivalMay2026">this month's
Emacs Carnival</a>, I'm recommending people try it for two separate
reasons.
</p>

<p>
The first reason is a sad one: <code>eww</code>'s limitations <i>improve</i> many
websites! I believe that <code>eww</code>'s biggest weakness, it's lack of
JavaScript, can also be a strength. It's sad how many websites <i>improve</i>
if you don't run their JavaScript code, which is often just there to
load ads or a paywall, or to make the text you are reading disappear
and reappear a couple of seconds later in a different (sometimes less
readable!) font. Similarly, many websites are simply hard to read: the
lines of text are ridiculously long, or the colors are garish, or the
text has too little contrast with the background (I blame that last
one on young web designers with great eyesight that don't understand
that many middle-aged people struggle to read medium gray text in a
thin font on a light gray background). The JavaScript problem is fixed
right out of the box with <code>eww</code> simply because it cannot run JavaScript.
By default eww does leave you a bit at the whims of websites with
respect to colors, but a simple <code>(setopt shr-use-colors nil)</code> will fix
that. You can read any website (well, many websites) in <code>eww</code> using your
favorite Emacs theme, a sensible line length and the fonts you've
chosen. (This part isn't unique to <code>eww</code>, of course, there are browser
extension you can use for the same purpose in normal web browsers).
</p>

<p>
The second reason is perhaps surprising: Emacs has many UI innovations
when compared to standard browsers! Interestingly the innovations I
have in mind are not made specifically for <code>eww</code>, but are broader Emacs
UI features. Here are a few I like that I don't think normal browsers
can match (please let me know if I'm wrong about that):
</p>

<ol class="org-ol">
<li>You can resize an individual image without resizing text or other
images! Use <code>image-increase-size</code>, bound by default to <code>i +</code> when the
point is on an image (and only then). I often find images are
slightly too small or way too big.</li>

<li>You can read text in multiple columns with <code>follow-mode</code>. I like
making Emacs full screen and using 3 columns. (Again, this is
something you can probably find a browser extension for, but it's
built-in to Emacs.)</li>

<li>You have two types of search: <code>isearch</code> and <code>occur</code>. The browsers I've
used, only have an <code>isearch</code>-style interface: it searches
incrementally while you type and you can navigate to the next of
previous match. But sometimes I want to create a list of all the
matches of some text in a web page and have that list stick around
to treat it as a sort of todo list, in Emacs you do that with
<code>occur</code>. You can ask for some number of lines of context around each
match by calling <code>occur</code> with a prefix argument. You can navigatev
among the matches by pressing <code>RET</code> or clicking on them in the occur
buffer, or by using <code>next-error</code> (<code>M-g n</code>) and <code>previous-error</code> (<code>M-g
   p</code>)---which work even without having the occur buffer visible. I
find occur invaluable if I'm doing an in-depth information search
online.</li>

<li><p>
You can evaluate code right from a webpage if you are reading it in
Emacs! If I'm reading a blog about Emacs, I'll often run the Emacs
Lisp code it mentions with <code>eval-last-sexp</code> (<code>C-x C-e</code>), which is super
convenient. But this isn't limited to Emacs Lisp, of course! If I'm
reading a blog post with some Python code, I'll open a Python REPL
with <code>run-python</code> and then send Python code to it for evaluation
directly from the eww buffer.
</p>

<p>
For this I use a small command I wrote to send text to the first
visible comint buffer it finds (I've replaced several "inferior"
major modes with just <code>comint-run</code> and this one command, which I bind
to <code>C-:</code>):
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span style="color: #0031a9; font-weight: bold;">defun</span> <span style="color: #602938;">send-to-comint</span> ()
  <span style="color: #304463; font-style: italic;">"Send active region or current line to a process in some window."</span>
  (<span style="color: #0031a9; font-weight: bold;">interactive</span>)
  (<span style="color: #0031a9; font-weight: bold;">if-let*</span> ((process (<span style="color: #0031a9; font-weight: bold;">cl-loop</span> for w in (window-list)
                              thereis (get-buffer-process (window-buffer w))))
            (input (buffer-substring-no-properties
                    (<span style="color: #0031a9; font-weight: bold;">if</span> (use-region-p) (region-beginning) (pos-bol))
                    (<span style="color: #0031a9; font-weight: bold;">if</span> (use-region-p) (region-end) (pos-eol)))))
      (<span style="color: #0031a9; font-weight: bold;">progn</span>
        (<span style="color: #0031a9; font-weight: bold;">setq</span> deactivate-mark t)
        (funcall
         (buffer-local-value 'comint-input-sender (process-buffer process))
         process input))
    (<span style="color: #6d5000; font-weight: bold;">user-error</span> <span style="color: #00598b;">"No process found"</span>)))
</code></pre>
</div></li>

<li>If you are an Org mode user, it's really nice to be able to use
<code>org-store-link</code> to grab a link to the web page you are reading with
URL and title. Now, this is not unique to <code>eww</code>, you can also use the
org capture protocol with browsers outside of Emacs, but it can be
a little fiddly to set up, and at least in my experience, you need
to authorize your browser to follow org-protocol links once per
domain, which is a bit of a hassle too.</li>

<li>You can navigate headings using <code>outline-next-heading</code>, and if you
are consult user, you can using <code>consult-outline</code> to jump to
particular heading selected with completion. I don't know why
traditional browsers don't provide this excellent functionality!</li>
</ol>

<p>
And finally, this is a minor point, but <code>eww-readable</code>, which reduces
clutter, is always available in eww buffers; browsers usually have a
"reader mode" too, but have some silly heuristics to decide which web
pages to show the button on and I find the button is often not
displayed when I want to use it!
</p>

<p>
So: give <code>eww</code> a shot! Yes, it is limited by not being able to run
JavaScript, but (1) that can also be an advantage sometimes, (2) your
"real" browser is always an <code>eww-browse-with-external-browser</code> (bound to
<code>&amp;</code>) away, and (3) Emacs's excellent UI gives you some stuff browsers
don't, at least not without extensions or inconvenience.
</p>

<p>
UPDATE: In point 6, instead of outline support, I mentioned a little
package I had in my configuration that provided imenu support. GitHub
user aikrahguzar told me in <a href="https://github.com/oantolin/emacs-config/issues/2">an issue filed</a> against my configuration
repository that Emacs already had outline support for eww buffers,
after which I promptly deleted my little package. The moral of the
story is to publish your configuration online so random kind-hearted
strangers can suggest improvements! Also, I confirmed once again that
I really love deleting code from my configuration.
</p>
]]></description>
</item>
<item>
<title>Exploring large amounts of data with completion</title>
<link>http://www.matem.unam.mx/~omar/apropos-emacs.html#exploring-data-with-completion</link>
<author>omar@im.unam.mx (Omar Antolín Camarena)</author>
<guid isPermaLink="false">http://www.matem.unam.mx/~omar/apropos-emacs.html#exploring-data-with-completion</guid>
<pubDate>Sat, 28 Feb 2026 14:42:00 -0600</pubDate>

<description><![CDATA[<p>
<i>Published: [2026-02-28 Sat]. Comments on <a href="https://mathstodon.xyz/@oantolin/116150164678646714">Mastodon</a>.</i>
</p>

<p>
When faced with a large amount of information I want my computer to
help me sift through it. I think I have a low "browsing-threshold" and
will rather quickly turn to searching rather than paging through and
reading. I already mentioned this psychological trait of mine when I
<a href="#the-case-against-which-key-a-polemic">complained about which-key</a>, and the solution I proposed there was to
use minibuffer completion instead of tiring your eyes. I particularly
recommend this strategy to sift through data when combined with the
<a href="https://github.com/oantolin/orderless">orderless completion style</a> ---because life is too short to always
remember the order words go in.
</p>

<p>
Here's another example where I used this strategy. I'm an academic and
often need to find out what journals there are in a given field and
some rough idea of how selective they are. I typically use the <a href="https://www.scimagojr.com/">SCImago
Journal Rank</a> database for this. I don't agree with the use of citation
metrics to evaluate academic work but (1) I need to work within a
system that uses them, (2) I don't have a good idea of what to replace
them with for some use cases. If I publish a paper in a journal not
listed in that database, that paper is sadly not going to help my
career ---and most journals are in that database, so it's really not
that hard to stick to listed journals. Also, there are times when I am
asked to evaluate the work of other academics, for hiring or promotion
decisions, or when writing letters of recommendation, and they'll
often have published in journals I'm unfamiliar with (since there are
literally thousands of academic journals that publish math papers
---and I'm sure math is small compared to many other fields!). In those
case I look the journal up to get some rough idea of how hard it was
to publish there. I'm the first to admit this situation is not ideal,
but I don't see how to avoid using some kind of journal ranking for
some of the tasks I'm required to perform.
</p>

<p>
Anyway, I used to use the SCImago website directly to look up
journals, but the user experience was lacking compared to minibuffer
completion in Emacs: first, the website doesn't show you any results
at all until you press enter; second, you can only search for word
fragments in journal titles. I wanted the full interactivity and
search flexibility of Emacs minibuffer completion with a UI like
<a href="https://github.com/minad/vertico">Vertico</a> and a completion style like Orderless ---the SCImago website
already supports the best Orderless feature: matching word fragments
in any order; but some journals are widely known by their initials and
the SCIMago website doesn't support searching that way. And finally,
I'm very, very often in Emacs when I need to look up journals, so
switching to my browser to do it was a small waste of time.
</p>

<p>
Now, it turns out you can download SCImago's data for each year in a
CSV file, so I downloaded the last several years of data. The file for
each year is around 10MB, so I filtered them to keep only journals
that publish at least some math papers, and joined the lists for each
year into a single file with around 15000 lines. The file is formatted
as a single Lisp list, one element per line, and each element
corresponds to a specific journal's ranking in one specific topic and
year. I then wrote an Emacs command that prompts me in the minibuffer
first for a journal name, and then prompts me again, this time for a
year and finally copies to the kill-ring the lists of topics and
rankings for that journal in that year. I almost never finish that
command: after finding the journal I want to look at, I see the topics
and ranking in the second minibuffer prompt and cancel the command
with <code>C-g</code>.
</p>

<p>
Sometimes I'm not after a particular journal, but want a list of
specialized journals in a field. In that case I'll run the command
type the field's name and then use <code>embark-export</code> to get a buffer
listing the matching journals. In that buffer, pressing <code>RET</code> on a
journal title will prompt you in the minibuffer for a year in order to
copy the topics and rankings to the kill-ring. Again, I usually just
read them and press <code>C-g</code>. Another way I use my command is as a form of
completion: I use it to insert the full title of a journal into the
current buffer using <code>embark-insert</code>. All in all, having this command
has been a real time-saver.
</p>

<p>
If anyone is curious to see the code, I have it in a <a href="https://github.com/oantolin/scimago">public
repository</a>, but I should warn people that:
</p>

<ol class="org-ol">
<li>the code to download the database files for each year using <code>wget</code> no
longer works, because SCImago now uses Cloudflare to check you are
human (so just download them manually), and,</li>

<li>the code to preprocess the SCImago CSV files into a single Lisp
file is written in the <a href="https://mlochbaum.github.io/BQN/">BQN programming language</a>.</li>
</ol>

<p>
I really like array languages for data munging tasks, but since the
point was to use the data in Emacs, I probably should have used Emacs
Lisp. And I probably would have if Emacs came with a CSV parser
(although BQN doesn't come with one either...). Anyway, the point here
is simply to illustrate the idea that minibuffer completion is a great
way to browse information when there is a lot of it (and for me, a
couple of screenfuls already counts as "a lot").
</p>

<p>
Oh, I almost forget to mention one amusing thing about the code: in
addition to the command I mentioned above, I wrote a second command
that also prompts for a journal title but then instead of prompting
again produces a buffer in <code>tabulated-list-mode</code> with the topics and
rankings for each year. I never use that command because the command I
described above can emulate it: using <code>embark-export</code> from the <i>second</i>
minibuffer prompt gets you an almost identical result! You'd think
that I, of all people, would have been able to tell this other command
was subsumed by the first one and Embark...
</p>
]]></description>
</item>
<item>
<title>Vim is composable</title>
<link>http://www.matem.unam.mx/~omar/apropos-emacs.html#vim-is-composable</link>
<author>omar@im.unam.mx (Omar Antolín Camarena)</author>
<guid isPermaLink="false">http://www.matem.unam.mx/~omar/apropos-emacs.html#vim-is-composable</guid>
<pubDate>Sun, 28 Dec 2025 15:10:00 -0600</pubDate>

<description><![CDATA[<p>
<i>Published: &lt;2025-12-28 Sun&gt;. Comments <a href="https://mathstodon.xyz/@oantolin/115799215103803114">on Mastodon</a>.</i>
</p>

<p>
I want to articulate something I find confusing. It's not about Vim,
but rather about Vim users. (And since this is an Emacs blog, I'll
also give some Emacs pointers along the way.) I used Vim for a few
years and still like it a lot. When forced to edit text in a non-Emacs
editor, I usually use the editor's Vim emulation mode because there is
very often a decent one.
</p>

<p>
Vim users often say that what makes Vim great is that it has a
composable text editing language, and they'll tell you that what that
means is that you choose separately what text to operate on and what
operation to perform on it, and can combine any operation with any way
to select text. And you can choose those components in any order: in
what is called normal mode you first choose an operation and then an
operand; but if you prefer to do it the other way around, you can use
Vim's visual mode.
</p>

<p>
Here's what really confuses me: Vim users never tell you that this
composable editing model, of choosing separately what text to operate
on and operation to perform on it, is extremely common and is built-in
to almost all text editors. They also don't say it is unique to Vim, I
don't think, but it still feels very odd to rave about composability
when it is a commonplace feature. It feels like a friend excited about
their new car telling you that the model he bought is crazy cool
because it has tires!
</p>

<p>
Even the lowly Windows Notepad is a composable text editor: to select
text you can highlight with the mouse, use shift and the arrow keys,
double click to select a word, or triple click to select a line; once
you've selected you text you can press backspace to delete it, ctrl+x
to cut it to the clipboard, ctrl+v to replace it with the contents of
the clipboard, etc. There's a dearth of operations in notepad, but
they all compose with the various means of selecting text.
</p>

<p>
I don't think I've ever used a single text editor that isn't
composable in the sense Vim users explain. To me that is not at all
what makes Vim special ---it can't be since all text editors do that!
What I find most special about Vim is the variety of operations and of
ways to select text. I specially like all the fine-grained
distinctions Vim has to say exactly what stretch of text you want to
act on. In Emacs I missed Vim's distinction between words and WORDS
(the all caps one means a maximal consecutive stretch of
non-whitespace characters), so I wrote a command <code>mark-non-whitespace</code>
to mark the WORD at point. In Vim when you move by words you can
decide whether you want to land just beyond the end of the word or at
the beginning of the next word, which I also missed in Emacs until I
found the <code>forward-to-word</code> command in <code>misc.el</code>, which I bind to <code>M-F</code>.
</p>

<p>
After the sheer variety of motions, text objects and commands in Vim,
I think what I like best is the help you get in automating editing
tasks. First, commands can take a numeric repetition count. I don't
think that is common in text editors. I'm sure there are some others
that do it but, of the ones I've used, only vi, Vim and Emacs do that,
that I can recall. Second, there is the marvelous dot command, that
repeats the last editing operation (I say "editing operation" as
opposed to commands that only move the cursor without modifying the
text you are editing). With <code>n</code> to repeat the last search and <code>.</code> to
repeat the last editing command, you can really fly over text making
parallel edits all over the place: <code>n.n.nn.</code> (two <code>n</code>'s in a row because I
wanted to skip one search result!). And third, there are keyboard
macros to automate more complex tasks. I haven't used VS Code, but I
have heard it doesn't have keyboard macros (except maybe in a plugin),
which sounds like a very hostile-to-automation way to design a text
editor.
</p>

<p>
Of course, Emacs also has ways of repeating the last command; there
are <code>repeat</code> and <code>repeat-complex-command</code>, for example. But the experience
in Vim with <code>.</code> is smoother and it illustrates a subtlety about the
composable editing model: Vim's <code>.</code> repeats the last combination of an
editing operation and text selection, those two parts are fused
together into a single repeatable unit. I guess you could say that is
a sense in which Vim is composable and many other editors are not
(though I don't often see Vim users making this point; they tend to
explain what they mean by composability as I did above, accidentally
describing every text editor in existence). In Emacs when you use
<code>repeat</code> or <code>repeat-complex-command</code> you only get the last Emacs command
repeated, which might only be half of the fused operation-selection
whole. To get an experience more similar to Vim's <code>.</code> in Emacs, you can
try the <a href="https://github.com/wyrickre/dot-mode">dot-mode</a> package, which makes a keyboard macros out of the
last consecutive stretch of buffer-modifying commands. In a way, I
like it even better than Vim's <code>.</code> command, because, and this will sound
funny: it's a little less stressful to use for certain personality
types. In Vim I constantly paused to think: "can I do the next edit in
a single command so that I can repeat the whole thing with <code>.</code>?", and
would be disappointed in myself whenever I made an edit using two or
more commands, soon after needed to repeat it and hadn't though to
record a macro, and doubly disappointed if I then realized I <i>could</i>
have done it in a single command! With dot-mode you can relax: you get
all the consecutive editing commands you made repeated, not just the
last one.
</p>

<p>
Nowadays I don't even use dot-mode in Emacs anymore, sticking to
keyboard macros. But I have made their use as frictionless for me as
possible. First, I bind <code>kmacro-start-macro-or-insert-counter</code> to <code>M-r</code>
and <code>kmacro-end-or-call-macro</code> to <code>M-m</code>, where find I them more readily
accessible than at the default bindings of <code>&lt;f3&gt;</code> and <code>&lt;f4&gt;</code> (specially
since on my laptop I need to press the <code>fn</code> key to use functions keys).
And I bind <code>M-n</code> to a command that repeats the last isearch so I can
play the <code>n.n.nn.</code> game in Emacs too by holding down the meta key and
going <code>nmnmnnm</code>:
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span style="color: #0031a9; font-weight: bold;">defun</span> <span style="color: #602938;">isearch-next</span> ()
  <span style="color: #304463; font-style: italic;">"Go to next isearch match."</span>
  (<span style="color: #0031a9; font-weight: bold;">interactive</span>)
  (<span style="color: #0031a9; font-weight: bold;">if</span> (equal isearch-string <span style="color: #00598b;">""</span>)
      (<span style="color: #6d5000; font-weight: bold;">user-error</span> <span style="color: #00598b;">"No previous search."</span>)
    (<span style="color: #0031a9; font-weight: bold;">let</span> (isearch-lazy-highlight)
      (isearch-repeat 'forward))
    (isearch-exit)))
</code></pre>
</div>

<p>
Now let me get back to what I like about Vim: so far I've said (1)
variety of operations and way to select text, especially the
fine-grained selection distinctions, (2) features for automation:
repeat counts, the dot command and keyboard macros. To that I'd add
(3) the concept of buffer: that text need not reside in a file to be
edited in Vim (this is also a key idea in Emacs, of course), and I
very often put text in a new temporary buffer to save it for later or
to edit it quickly and paste somewhere else; and, of course, (4)
extensive customizability. As you can see what I like about Vim is
basically also what I like about Emacs. What can I say? When it comes
to text editors I definitely have a type!
</p>

<p>
Of course, some Vim users do also mention all the other neat features
of Vim that I like, but why are there so many blog and forum posts
about Vim's composability that don't mention this is the normal way
for text editors to be designed? Here are a few conjectures, none of
which I really believe:
</p>

<ul class="org-ul">
<li>Vim users who talk about composability have never used any other
text editor and don't know those are composable too. This would
explain the situation but seems exceedingly unlikely.</li>
<li>Vim users think that Vim does composability better than other
editors but fail to explain in what ways is better and wind up
describing composability in a way that other editors also have. This
is possible: explaining things is hard (I do it for a living and am
still terrible at it); and there are ways in which composability in
Vim is better, namely the <code>.</code> command repeating an edit comprising an
operation-selection pair.</li>
<li>Vim users don't really believe other text editors lack
composability, what truly bothers them is that in addition to
composability other editor also offer as shortcuts some fused
operation-selection combos. For example Emacs will let you mark a
region by any means you wish and then compose that with a
<code>kill-region</code> command, but it also offers <code>kill-word</code>, <code>kill-line</code>,
<code>kill-sentence</code>, <code>kill-paragraph</code>, etc. Maybe what Vim users really like
is Vim's principled insistence in not offering shortcuts, making you
always specify an operation and a target text separately? I don't
think this either matches what they say or makes much sense really
---why would it bother you that other software offers additional
shortcuts? (Also, Vim does have a few shortcuts: for example, in
insert mode <code>&lt;C-w&gt;</code> deletes the previous word.)</li>
</ul>

<p>
To me the prevalence of people saying "Vim is great because it is
composable" and then explaining composability in a way that applies to
every text editor I've ever used is just one of life's mysteries.
</p>
]]></description>
</item>
<item>
<title>Elevator pitch</title>
<link>http://www.matem.unam.mx/~omar/apropos-emacs.html#elevator-pitch</link>
<author>omar@im.unam.mx (Omar Antolín Camarena)</author>
<guid isPermaLink="false">http://www.matem.unam.mx/~omar/apropos-emacs.html#elevator-pitch</guid>
<pubDate>Thu, 21 Aug 2025 07:21:00 -0600</pubDate>

<description><![CDATA[<p>
<i>Published: [2025-08-21 Thu]. Comments <a href="https://mathstodon.xyz/@oantolin/115066955008031013">on Mastodon</a>.</i>
</p>

<p>
Software is generally terrible. It's buggy and slow, despite computers
being ridiculously fast. And even when it's not buggy it often does
something weird or that isn't quite what you want. When I saw the call
for <a href="https://takeonrules.com/2025/08/01/emacs-carnival-2025-08-your-elevator-pitch-for-emacs/">this month's Emacs Carnival</a> asking for elevator pitches for Emacs,
I started collecting bugs and oddities in the software I use. I don't
want to pick on some poor indie programmer, so here's a list of bugs
or odd behaviors I've observed during just this month in software from
Google and Facebook:
</p>

<ul class="org-ul">
<li>A boat load of YouTube bugs or quirks:
<ul class="org-ul">
<li>Play/pause button doesn't always show the right state.</li>
<li>The speed control UI is randomly selected among about 3 different ones.</li>
<li>Sometimes when double tapping to rewind 10 seconds, the playback
speed is reset to 1x.</li>
<li>Changing the playback speed sometimes does nothing.</li>
<li>Sometimes when you open the Android app, you get a tiny black rectangle
in the corner that I can't figure out how to interact with. I wind
up just restarting the application.</li>
</ul></li>

<li>In the YouTube Music app, finished podcast episodes sometimes don't
show up as "played". Leaving the list of downloaded episodes and
returning to it fixes this.</li>

<li>On the Facebook webpage the animations for reactions don't load for
me anymore. (Luckily hovering on the blank space shows a tool-tip
stating which reaction it is.) I'd be perfectly happy with static
images or even text...</li>

<li>The Google search page can be configured to match your system dark
mode preference. But it isn't fully automatic, for a change to
register, even in brand new browser tabs, you have to reload (or go
into settings, not to change anything, just going into settings is
enough!).</li>

<li>The battery indicator on my Android phone occasionally doesn't show
that the phone is plugged in until I reboot it.</li>
</ul>

<p>
And there's nothing I can do about any of this! I guess I could try to
report the bugs and hope someone fixes them, but the play/pause
problem seems to be about a decade old from what I've read online so
I'm not holding my breath.
</p>

<p>
My elevator pitch for Emacs is simply: <i>you don't have to put up with
any of this crap in Emacs!</i> You can just fix any bug or behavior you
dislike without waiting for anyone! I often notice something I don't
like, fix it in my personal configuration, and only afterwards report
the bug (and usually I then monitor updates to that piece of software
to see when I can remove my personal workaround).
</p>

<p>
Now, you might think the problem is that I use proprietary software,
and that if I only used open source software all my computing
experience would be Emacsian, that I'd be fixing bugs left and right.
No, I wouldn't! Emacs makes this as frictionless as possible. For most
open source software I use, I don't even have the source code
installed (because that's not the default in Debian's package manager:
I'd have to go out of my way to get the source code). Even if I had
the source code, it would be hard to figure out where the code
responsible for the behavior I want to change even is and I'd have to
restart the program to test any changes I make, probably several
times. With Emacs this is all a breeze, I can:
</p>

<ul class="org-ul">
<li>jump directly to the source code of the command that I just used
(and if I don't know what command that is, or what keys I pressed to
cause it to run, I can ask that too);</li>
<li>make any modifications and try the new code immediately without
restarting Emacs;</li>
<li>when I get it right, I can add code to my personal configuration
incorporating the fix without touching the original source code.</li>
</ul>

<p>
I know myself: I <i>need</i> all of that convenience to fix problems or I
just won't do it. Most fixes take a few minutes and that's the only
reason I'm willing to make them. I've gotten pretty good at making
Emacs do <i>exactly</i> what I want and I'm not a software developer, I
imagine that for them the experience is even smoother!
</p>
]]></description>
</item>
<item>
<title>Ten things to try with Embark</title>
<link>http://www.matem.unam.mx/~omar/apropos-emacs.html#ten-things-to-try-with-embark</link>
<author>omar@im.unam.mx (Omar Antolín Camarena)</author>
<guid isPermaLink="false">http://www.matem.unam.mx/~omar/apropos-emacs.html#ten-things-to-try-with-embark</guid>
<pubDate>Thu, 24 Jul 2025 00:34:00 -0600</pubDate>

<description><![CDATA[<p>
<i>Published: [2025-07-24 Thu]. Comments <a href="https://mathstodon.xyz/@oantolin/114906814617670439">on Mastodon</a>.</i>
</p>

<p>
This is my first listicle! (I apologize in advance for it, and hope
not to do this too often.) Here are 10 not-so-obvious things to try
with <a href="https://github.com/oantolin/embark">Embark</a>, written as a response to <a href="https://www.reddit.com/r/emacs/comments/1m7k80r/what_are_your_most_useful_use_cases_for_embark_or/">this reddit question</a>.
</p>

<p>
I'll use <code>&lt;act&gt;</code> to represent whatever key binding you have
for <code>embark-act</code>, and <code>&lt;dwim&gt;</code> to denote the binding for <code>embark-dwim</code>.
</p>

<ol class="org-ol">
<li>If I'm looking at some project's README file and it mentions some
command I should run (for example, to install the project), I don't
copy the command, start or switch to a shell, and then paste the
command. Instead I select the command, and use <code>&lt;act&gt; M-!</code> (or
<code>&lt;act&gt; M-&amp;</code>) to directly pass the command to <code>shell-command</code> (or
<code>async-shell-command</code>). Notice that <code>M-!</code> is just the global
binding for <code>shell-command</code>. In embark you can use any command as
an action, you are not limited to the commands in the embark
keymaps (those keymaps are just for convenience); you can specify
the command with any key binding you have for it, or even by using
<code>M-x</code>. (I've been asked more than once to <b>remove</b> this freedom and
limit users to pre-registered commands from the embark keymaps,
which seems insane to me, and I refused all such requests!)</li>

<li>I use <a href="https://github.com/minad/jinx">jinx</a> for spellchecking in both English and Spanish, and
sometimes I want to add a word (usually a proper name) to my
personal dictionaries for both languages. To do that I take
advantage of the fact that while <code>jinx-correct</code> is running, <b>that</b> is
the default action, i.e., <code>embark-dwim</code> will run <code>jinx-correct</code>. So if
I have <code>embark-quit-after-action</code> set to <code>nil</code> (which I prefer), I can
add the word to one dictionary using <code>&lt;dwim&gt;</code> instead of <code>RET</code>, and
this keeps <code>jinx-correct</code> open so I can still add it to the other
dictionary (this time using <code>RET</code>, so <code>jinx-correct</code> now finishes).</li>

<li>Similarly to the previous example, when writing an email I can run
<code>mml-attach-file</code> and use <code>embark-dwim</code> to attach several files in
one go. This is useful because I often need to attach several files
from the same directory, and using a single run of
<code>mml-attach-file</code> saves me from having to navigate several times to
the directory. In fact, often the files I need to attach all have
something in common in their name, say, I need to send all files of
the form <code>report-$MONTH-2025.pdf</code>. Then I can run
<code>mml-attach-file</code>, navigate to the directory containing them, type
<code>report 2025</code>, which under Orderless will match exactly the files I
want, and then run <code>&lt;act&gt; A RET</code>, which will run the default action
(attaching) on all of them.</li>

<li>If I'm reading Emacs's info documentation, and it mentions some
command I want to try, I put point on the command name and use
<code>&lt;act&gt; x</code> (for commands, <code>x</code> is bound to
<code>execute-extended-command</code>). If it mentions some variable and I
want to customize it, <code>&lt;act&gt; u</code> (for variables, <code>u</code> is bound to
<code>customize-variable</code>). I used to copy and paste a lot more, to get
inputs to commands, but Embark let's me send things directly to the
commands that use them.</li>

<li>Any command that prompts for widgets becomes a widget manager! For
example, I use dired a lot less than I used to, since I now do most
of my file management from inside <code>find-file</code>: I use <code>embark-act</code>
from inside <code>find-file</code> to delete, rename, copy, or open files with
external programs. Similarly, I do most package management from
inside <code>describe-package</code>, using <code>embark-act</code> to install,
uninstall, view the homepage or description for a package.
Similarly, if I want to toggle, customize, or find out the current
value of a variable, I'll do it from <code>describe-variable</code>. I use
<code>find-library</code> not just to open a library, but also to load one, or
to view the commentary or info manual. I only need to remember (or
even have) the key bindings for the commands I use as entry points,
and Embark reminds me of the rest.</li>

<li>If see you some arithmetic operations written in a buffer
somewhere, you can print the result in the echo area by selecting
that text and sending it to <code>quick-calc</code> with <code>&lt;act&gt; C-x * q</code> (if
you do this often, you might want a better keybinding for
<code>quick-calc</code> than the default <code>C-x * q</code>). With a universal prefix
argument, <code>quick-calc</code> will insert the result in the buffer instead
of just echoing it; I used this to compute that 30!
= 265252859812191058636308480000000. Similarly if you want to add a
column of numbers, select the numbers and use <code>&lt;act&gt; :</code> (for
regions, <code>:</code> is bound to <code>calc-grab-sum-down</code>).</li>

<li>I even use <code>&lt;dwim&gt;</code> instead of <code>C-x C-e</code> to evaluate expressions
for several reasons: (1) my keybinding for <code>embark-dwim</code> is shorter
than <code>C-x C-e</code>, (2) I can place point either before the opening
parenthesis or after the closing one (or even use <code>&lt;act&gt;</code> from
anywhere in the middle of the s-expression and cycle to the
s-expression target), (3) the default action in Embark for
s-expressions is <code>pp-eval-expression</code>, so you get pretty-printing
too! Another nice action on s-expressions is <code>embark-eval-replace</code>
(bound to <code>&lt;</code>), which <b>replaces</b> the s-expression with its value.</li>

<li>Sometimes I'll use <code>M-!</code> to run a shell command and while I'm
typing the full command realize I forgot exactly how you use the
program (maybe I forgot what an option is called, or the order of
the arguments), in that case, I put point on the command name and
run <code>&lt;act&gt; M-x man</code> to pop up the man page while I keep working on
typing in the command.</li>

<li>Embark tries to use the same key binding for conceptually similar
actions. For example <code>h</code> is <code>describe-symbol</code>, <code>describe-face</code>,
<code>finder-commentary</code>, or <code>describe-package</code> depending on what you
act on. I try to extend that as much as possible in my personal
configuration. For identifiers in programming modes that are not
Emacs Lisp, Embark binds <code>h</code> to <code>display-local-help</code>, which isn't
very useful on its own, but you can remap it to something better,
For example, in shell script buffers (and in shell buffers) I remap
<code>display-local-help</code> to <code>man</code>, and in perl-mode buffers I remap it
to <code>cperl-perldoc</code>. That way I can still get help for the thing at
point with <code>&lt;act&gt; h</code> in those buffers.</li>

<li>I use <code>org-ql-find</code> or <code>consult-org-heading</code> to search my org
files and I use <code>embark-act</code> to do things to the headings right
from the minibuffer without losing my place. Particularly useful
are <code>I</code> and <code>O</code> which are bound to <code>org-clock-in</code> and
<code>org-clock-out</code>. To link to a heading, I used to navigate to the
heading, use <code>org-store-link</code>, navigate back to where I wanted the
link (usually easy by popping the global mark) and then use
<code>org-insert-link</code>. But now, I just search for the heading I want
to link to with org-ql or consult, and use <code>&lt;act&gt; j</code> to insert the
link, it's super fast and convenient, and I find myself
interlinking my notes much more now (I guess this is one of the
things people like about org-roam, too). Similarly if I want to
link to a bunch of headings I can usually craft and org-ql query
that matches exactly the ones I want, then I use <code>&lt;act&gt; A l</code>, to
call <code>embark-act-all</code> with <code>org-store-link</code> as the action, and
finally I use <code>org-insert-all-links</code> to insert all links as an
itemized list.</li>
</ol>
]]></description>
</item>
<item>
<title>Writing Experience</title>
<link>http://www.matem.unam.mx/~omar/apropos-emacs.html#writing-experience</link>
<author>omar@im.unam.mx (Omar Antolín Camarena)</author>
<guid isPermaLink="false">http://www.matem.unam.mx/~omar/apropos-emacs.html#writing-experience</guid>
<pubDate>Mon, 21 Jul 2025 04:10:00 -0600</pubDate>

<description><![CDATA[<p>
<i>Published: [2025-07-21 Mon]. Comments <a href="https://mathstodon.xyz/@oantolin/114890671803436392">on Mastodon.</a></i>
</p>

<p>
This blog entry is part of the Emacs Carnival for July 2025, <a href="https://gregnewman.io/blog/emacs-carnival-2025-07-writing-experience/">hosted by
Greg Newman</a>, with the topic of "Writing Experience".
</p>

<p>
I mostly use Emacs to write prose, not because I don't also use Emacs
to write computer programs, but simply because I write a whole lot
more prose than code! I write papers, lecture notes, homework
assignments, notes on different topics (some public, some private), my
website including this blog, emails, comments on social networks, and
I'm even supposed to be keeping a journal (though I notice the most
recent entry is from April...).
</p>

<p>
But more than that, I tend to write any bit of text longer than a
sentence or two in Emacs. The main the reason for that is that I edit
a lot as I write and Emacs makes this easier than any other text
editor I'm aware of. Before Emacs I used Vim and, while it is a very
powerful text editor, it has distinct modes for inserting text (called
insert mode, naturally) and for editing it (called normal mode, to
mock writers for being imperfect and <i>normally</i> requiring editing). The
separation of modes nudges you in the direction of getting a first
rough draft down and then editing it. That suits some people
perfectly, and it is certainly something I could do and was used to,
but I think that I am naturally more of an edit-as-you-go person. My
evidence for this is that it is what I do in Emacs, which favors
neither the draft-first nor the edit-as-you-go style ―it's pretty much
the same number of keystrokes either way, unlike in Vim where you give
the poor <code>ESC</code> key a break if you batch your edits.
</p>

<p>
By the way, the fact that I spend so much time editing prose is also
why I need a text editor like Emacs or Vim and couldn't switch to a
code editor like VS Code. When an editor calls itself a "code editor",
my impression is that it does so to signal poor support for prose (or
maybe it wants to signal good support for code ―I needn't be so
negative). I don't think VS Code has commands to move by or select
sentences, for example; instead it's line-oriented, which makes sense
for programming ―or, I guess, for people who write prose one sentence
per line because they use <code>git</code> and want cleaner diffs but don't know
about <code>git diff --word-diff</code>.
</p>

<p>
Emacs is very powerful out of the box for editing prose, but even so I
have a few personal tweaks to make it fit me like a glove. In the rest
of this blog post I will describe a few commands I use when editing
prose, some built-in, some I wrote myself to scratch a small but
persistent itch.
</p>
<div id="outline-container-orgd5d0df0" class="outline-3">
<h3 id="orgd5d0df0">Changing case and transposing</h3>
<div class="outline-text-3" id="text-orgd5d0df0">
<p>
One of my most common typos is being slow to release the shift key and
accidentally capitalizing the first two letters of a word, as in "See
you next THursday!". When I make that mistake I often notice it before
I finish typing that word and in stock Emacs I could fix it right away
with <code>M-- M-c</code> or <code>M-b M-c</code>. (By default <code>M-c</code> is bound to <code>capitalize-word</code>,
but I recommend rebinding it to <code>capitalize-dwim</code> which acts as
<code>capitalize-word</code> unless there is an active region in which case it acts
as <code>capitalize-region</code>.) At some point I noticed that my most common use
of <code>M-c</code> was to capitalize the previous word, and decided to simplify
that case. Initially I wrote a command that is just like
<code>capitalize-dwim</code> except that if point is at the end of the word it acts
on the previous word rather than on the next one. That did simplify my
most common usage of <code>M-c</code> but it introduced a new problem: when I
wasn't fixing a typo in a word I just entered, I often forgot the new
behavior and expected <code>M-c</code> to capitalize the next word, even if point
was at the end of a word; in those cases my new command annoyed me
quite a bit.
</p>

<p>
This illustrates what I feel is an underappreciated point: the user
experience (UX) of even simple editing commands is often tricky to get
exactly right. Of course, people are aware that UX design is hard, but
I think people tend to assume it's only hard for larger programs, not
for something tiny like <code>capitalize-word</code>. But for a command you are
likely to use many times a day getting the UX exactly right really
pays off. I eventually fixed my command drawing inspiration from a
different set of commands that are also extremely useful while writing
prose: the tranpose family of commands. I'll explain the feature of
these commands that I adopted for the case change commands, after I
explain what they do. The transpose commands are fantastic and I don't
understand why not every editor has them (even Vim doesn't!). Another
extremely common typo I make is swapping two charcaters. To fix that,
you put point on the second of the characters (if your cursor is a
bar, put the bar between the swapped characters) and use
<code>transpose-chars</code>, bound by default to <code>C-t</code>. There are also
<code>tranpose-words</code> (<code>M-t</code>), <code>transpose-sexps</code> (<code>C-M-t</code>), <code>transpose-lines</code>
(<code>C-x C-t</code>), <code>transpose-sentences</code> and <code>transpose-paragraphs</code>.
The sexp and line commands are more useful for editing code than
prose, but are still useful for prose, particular since parenthetical
expressions or quoted text count as sexps. It's a little sad that the
sentence and paragraph commands are not bound by default; I bind them
to <code>M-T</code> and <code>C-x M-t</code> respectively. While <code>transpose-chars</code> is most useful
for fixing typos, the other transpose commands are more useful while
editing. I find I rearrange text quite a bit: Even for a 5−10 line
email I'm fairly likely to have swapped two sentences or even two
paragraphs while writing it!
</p>

<p>
The transpose family of commands have a few very nifty features:
</p>

<ol class="org-ol">
<li>They leave point after the second of the two swapped things, which
means that by simply repeating the command you can continue to move
that thing to the right. With a negative prefix argument you can
drag things to the left instead.</li>
<li>With a prefix argument of 0 they can swap non-adjacent things!
Select a region starting somewhere in the first thing and ending
somewhere in the second and call a transpose command with a prefix
argument of 0 to swap them,</li>
<li>If you use <code>transpose-chars</code> at the end of a line you might think it
would swap the last character of the line with the newline, since,
that newline is after all the next character, but instead it swaps
the last two characters on the line. This means that if you
accidentally swap two characters while entering text (at the end of
some line) and notice the typo immediately, you can fix it with
just <code>C-t</code> without moving the point! This is special behavior of
<code>transpose-chars</code>, sadly not shared by <code>transpose-words</code>, but at least
that one has a similar but lesser magic: if you use <code>transpose-words</code>
at the end of the <i>buffer</i> (yes, I said "buffer", not "line"), it
will&hellip; not swap the last two words, but produce an error message.
and also move point to before the last word. But that very last bit
means that a second <code>M-t</code> will swap the last two words! OK, kind of
lame compared to <code>C-t</code> but at least it's something.</li>
</ol>

<p>
That last behavior of <code>transpose-chars</code> is what I adopted for my
versions of the case-change dwim commands: if you call one of my
case-change commands at the end of a line, it changes the case of the
last word of the line (not the first word on the next non-blank line,
which is what <code>capitalize-word</code> or <code>capitalize-dwim</code> would do). And that
feels perfect to me: my common typo is fixed with a simply <code>M-c</code> but
while editing text in the middle of the text I don't get any
unpleasant surprises anymore. Try teaching that to a web browser text
input box!
</p>
</div>
</div>
<div id="outline-container-orga2d71d4" class="outline-3">
<h3 id="orga2d71d4">Marking whole words</h3>
<div class="outline-text-3" id="text-orga2d71d4">
<p>
Another tiny annoyance I had with the built-in commands is that the
marking commands only mark from point to the end of the thing they are
for. For example <code>mark-word</code> does not mark the word at point, it marks
the portion of that word starting at point (so if point is on the
first character of the word, it does mark the entire word). The
analogous command for sentences has more honest name:
<code>mark-end-of-sentence</code> ―though <code>mark-to-end-of-sentence</code> would be even
clearer. Now, for sentences, that behavior seems fine and useful to
me, since I often do want to grab just the tail of a sentence, but I
basically never want to mark just a piece of a word. So I wrote a
command that marks the entire word point is on, bound it to <code>M-@</code> and
just use it in place of <code>mark-word</code>. Obviously I called my command
<code>mark-my-word</code>.
</p>
</div>
</div>
<div id="outline-container-org2a9ee63" class="outline-3">
<h3 id="org2a9ee63">Useful commands with no default key binding</h3>
<div class="outline-text-3" id="text-org2a9ee63">
<p>
That <code>mark-end-of-sentence</code> command I mentioned doesn't have a default
key binding, but that's OK since you can achieve the same effect by
using shift selection with the <code>forward-sentence</code> command (I mean typing
<code>M-E</code>). But there are some very useful commands, particularly in the
<code>misc.el</code> library, with no key binding:
</p>

<ul class="org-ul">
<li><code>zap-up-to-char</code>, which I find I want more often than <code>zap-to-char</code>, so
I bind this one <code>M-z</code> and <code>zap-to-char</code> to <code>M-Z</code>.</li>
<li><code>forward-to-word</code> and <code>backward-to-word</code> which move to the opposite end
of the word than <code>forward-word</code> and <code>backward-word</code> do; I bind these to
<code>M-F</code> and <code>M-B</code>.</li>
<li><code>copy-from-above-command</code> and <code>duplicate-dwim</code>, two commands that can
duplicate a line. The first duplicates the line above point and the
second duplicates the line at point. The first command actually
duplicates the tail of the line above starting from the current
column, and if given a numeric argument will only duplicate that
many characters (I hardly ever use this last bit of functionality
since I find counting characters tedious and error prone). The
second command will duplicate the region if it is active ―which is
what <code>dwim</code> means in several Emacs commands.</li>
<li><code>delete-forward-char</code> is a surprising one: by default <code>C-d</code> is bound to
<code>delete-char</code> but the documentation for that command says: "The
command ‘delete-forward-char’ is preferable for interactive use,
e.g. because it respects values of ‘delete-active-region’ and
‘overwrite-mode’." I agreed and rebound <code>C-d</code>.</li>
<li><code>kill-paragraph</code>, I bind this to <code>M-K</code>.</li>
<li><code>up-list</code> moves you out of a delimited expression, which honestly is
more useful when writing code, but I mention it here since I do use
it often for getting out of parenthetical remarks or quotation
marks. I bind to <code>C-M-o</code> which goes well with the other sexp
navigation commands with <code>C-M-</code> modifiers; the mnemonic for <code>o</code> is that
it gets me Out of a sexp.</li>
<li><code>transpose-sentences</code> and <code>transpose-paragraphs</code> I already mentioned
above. I bind them to <code>M-T</code> and <code>C-x M-t</code>. In org-mode buffers you don't
really need <code>transpose-paragraphs</code> since <code>M-&lt;down&gt;</code> and <code>M-&lt;up&gt;</code> cover its
functionality.</li>
</ul>
</div>
</div>
<div id="outline-container-orgaf8908c" class="outline-3">
<h3 id="orgaf8908c">Dabbrev</h3>
<div class="outline-text-3" id="text-orgaf8908c">
<p>
The kind of "autocompletion" I almost always want while writing prose
is simply to complete text I've already typed somewhere. For that
<code>dabbrev-expand</code> (bound to <code>M-/</code>) is super useful: it'll search for
completions of the beginning of a word you've typed in several places
in order: the current buffer before point, the current buffer after
point, other buffers in the same major mode as the current buffer, and
finally all other buffers. (That's just the default configuration, as
usual in Emacs, dabbrev is quite configurable.) I often find myself
opening some file just so I can complete words from it in another
buffer. One lesser known feature of <code>dabbrev-expand</code> is that you can
also use it to complete phrases, not just words: if right after
completing a word using <code>dabbrev-expand</code> you insert a space and then run
<code>dabbrev-expand</code> again, it will insert the word that followed the first
word wherever it found it. So <code>M-/ SPC M-/ SPC M-/ ...</code> will complete a
phrase from your buffer. To make this even more convenient I wrote
this little command that I bind to <code>M-;</code>:
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span style="color: #0031a9; font-weight: bold;">defun</span> <span style="color: #602938;">dabbrev-next</span> (arg)
  <span style="color: #304463; font-style: italic;">"Insert the next ARG words from where previous expansion was found."</span>
  (<span style="color: #0031a9; font-weight: bold;">interactive</span> <span style="color: #00598b;">"p"</span>)
  (<span style="color: #0031a9; font-weight: bold;">dotimes</span> (_ arg)
    (insert <span style="color: #00598b;">" "</span>)
    (dabbrev-expand 1))
  (<span style="color: #0031a9; font-weight: bold;">setq</span> this-command 'dabbrev-expand))
</code></pre>
</div>

<p>
That way I can complete a phrase with <code>M-/ M-; M-; ...</code>. You can really
fly that way. For example, the previous paragraph says "current
buffer" three times; I only wrote the first one in full, the others
were <code>cur M-/ M-;</code>.
</p>
</div>
</div>
<div id="outline-container-orgff2ba67" class="outline-3">
<h3 id="orgff2ba67">Ediff</h3>
<div class="outline-text-3" id="text-orgff2ba67">
<p>
This one isn't so impressive to computer programmers, used as they are
to source control, but let me tell you that the ease with which you
can merge versions of files using <code>ediff</code> will absolutely blow
mathematicians minds! I've impressed several coauthors by merging our
changes to a draft paper in less than a minute, flying over changes
faster than they can orient themselves. It feels like a super power to
people who haven't seen something like it before.
</p>
</div>
</div>
<div id="outline-container-org0a912b1" class="outline-3">
<h3 id="org0a912b1">Keyboard macros</h3>
<div class="outline-text-3" id="text-org0a912b1">
<p>
I don't think it would surprise anyone to say that keyboard macros are
very useful for automating edits while coding, but perhaps it is a
little surprising they can also be very useful while editing prose.
One thing that comes up fairly often for me is that I want to write a
bulleted list and I have the raw data I need to talk about in some
other format. For example I might have a spreadsheet (if it's shared)
or an org table (if I'm the only one editing) with a list of names,
email addresses and affiliations of some people and I need to write a
small paragraph about each person. Here's an example with fake people:
</p>

<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">


<colgroup>
<col  class="org-left" />

<col  class="org-left" />

<col  class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left">Juana Sinisterra</td>
<td class="org-left">jsinis@uni.junco</td>
<td class="org-left">Universidad del Junco</td>
</tr>

<tr>
<td class="org-left">Molly Edwards</td>
<td class="org-left">medwards@henkin.edu</td>
<td class="org-left">Henkin College</td>
</tr>

<tr>
<td class="org-left">Mario Finetti</td>
<td class="org-left">mfino@vallebruna.it</td>
<td class="org-left">Universitá di Vallebruna</td>
</tr>
</tbody>
</table>

<p>
And I want to turn it into:
</p>

<ul class="org-ul">
<li>Juana Sinisterra &lt;jsinis@uni.junco&gt; from Universidad del Junco, XXX.</li>
<li>Molly Edwards &lt;medwards@henkin.edu&gt; from Henkin College, XXX.</li>
<li>Mario Finetti &lt;mfino@vallebruna.it&gt; from Universitá di Vallebruna,
XXX.</li>
</ul>

<p>
where the "XXX" are placeholders I'll fill in later. (I'd actually use
<code>&lt;++&gt;</code> as the placeholders and fill them in using my <a href="https://github.com/oantolin/placeholder">placeholder
package</a>, but never mind that now.) For this I'd record a keyboard
macro that transforms a single row of the table and just run it for
each line. For dealing with keyboard macros I prefer the "modern"
interface, consisting of <code>kmacro-start-macro-or-insert-counter</code> (bound
to <code>&lt;f3&gt;</code>) and <code>kmacro-end-or-call-macro</code> (bound to <code>&lt;f4&gt;)</code>, which can be
used in place of all four of these "old" key bindings: <code>C-x (</code>, <code>C-x C-k
C-i</code>, <code>C-x )</code> and <code>C-x e</code>. However I find the function keys a little too
far for comfort, so I rebind the commands to <code>M-r</code> (for "record") and
<code>M-m</code> (for "macro"). (<code>M-m</code> is bound by default to <code>back-to-indentation</code>, a
command which I do use but rebound to the more mnemonic <code>M-i</code>; <code>M-r</code> also
has a default binding, but I never use that command). Since I switched
to the simpler "modern" macro commands I find that I use keyboard
macros a lot more, and rebinding them to the highly accesible <code>M-r</code> and
<code>M-m</code> keys gave my macro usage a further boost.
</p>

<p>
In the example I gave above, I wanted to run the keyboard macro to
every line of a table. You can do that by recording the macro, marking
the remaining lines and using <code>apply-macro-to-region-lines</code> bound to <code>C-x
C-k r</code>. That key binding is a little awkward and to be honest I don't
use it: Embark binds that command to <code>m</code> when you are acting on a
region, so I use <code>C-. m</code> (simpler key bindings are a nice perk of
Embark's contextuality). But there is further convenience to be
enjoyed: as in this example, I very often want to apply a macro to
every line of a "paragraph" (a table with a blank line after it
counts), or rather, to the remaining lines of a paragraph after
recording the macro for the first line. For that I wrote this simple
command I bind to <code>M-M</code>:
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span style="color: #0031a9; font-weight: bold;">defun</span> <span style="color: #602938;">apply-macro-to-rest-of-paragraph</span> ()
  <span style="color: #304463; font-style: italic;">"Apply last keyboard macro to each line in the rest of the current paragraph."</span>
  (<span style="color: #0031a9; font-weight: bold;">interactive</span>)
  (<span style="color: #0031a9; font-weight: bold;">when</span> defining-kbd-macro (kmacro-end-macro nil))
  (apply-macro-to-region-lines
   (line-beginning-position 2)
   (<span style="color: #0031a9; font-weight: bold;">save-excursion</span> (end-of-paragraph-text) (point))))
</code></pre>
</div>

<p>
It feels like magic: <code>M-r</code>, do stuff to the first line, <code>M-M</code> and boom,
the same transformation gets applied to the rest of the lines!
</p>
</div>
</div>
]]></description>
</item>
<item>
<title>The case against which-key: a polemic</title>
<link>http://www.matem.unam.mx/~omar/apropos-emacs.html#the-case-against-which-key-a-polemic</link>
<author>omar@im.unam.mx (Omar Antolín Camarena)</author>
<guid isPermaLink="false">http://www.matem.unam.mx/~omar/apropos-emacs.html#the-case-against-which-key-a-polemic</guid>
<pubDate>Fri, 04 Jul 2025 17:28:00 -0600</pubDate>

<description><![CDATA[<p>
<i>Published: [2025-07-04 Fri]. Comments <a href="https://mathstodon.xyz/@oantolin/114797585280691160">on Mastodon</a>.</i>
</p>

<p>
It's Friday and jcs over at <a href="https://irreal.org/blog/">Irreal</a> has started a tradition of being
polemical on what he calls <i>Red Meat Fridays</i>. I'm joining in on the fun
today to explain why I don't like <code>which-key</code> ―but going somewhat
against the red meat spirit I don't want to merely criticize: I'll
offer up a suggestion of something better at the end, too.
</p>

<p>
What <code>which-key-mode</code> does is popup in the echo area a list of key
bindings and commands found under the current prefix. Here's what it
looks like after I pressed <code>C-x C-k</code> waited a second for the popup to
appear:
</p>


<div id="orgbd2d44a" class="figure">
<p><img src="http://www.matem.unam.mx/~omar/files/which-key-example.png" alt="which-key-example.png" />
</p>
</div>

<p>
Since the commands under <code>C-x C-k</code> didn't all fit on a single page,
<code>which-key</code> splits them into multiple pages and you can advance through
them with <code>C-h n</code> and <code>C-h p</code>. Reading through the <code>which-key</code> popup is a
great way to learn what is bound under a prefix. People love this and
<code>which-key</code> is now bundled with Emacs.
</p>

<p>
So why don't I like it? There's a minor reason and a major reason. The
minor reason is simply that it is automatic by default. The default
configuration has the <code>which-key</code> popup appear 1 second after typing a
prefix. Some people love this because it pops up precisely when they
don't know or can't remember what key to press next. I dislike almost
all forms of automatically appearing UI finding them jittery and
distracting; I almost always prefer to summon UI explicitly with a key
press or maybe mouse action. I understand this only a personal
preference, and it is an easily fixed one at that! There is a simple
way to configure <code>which-key</code> to wait for you to type <code>C-h</code> to appear:
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span style="color: #0031a9; font-weight: bold;">setq</span> which-key-show-early-on-C-h t
      which-key-idle-delay 1e6 <span style="color: #7f0000; font-style: italic;">; </span><span style="color: #7f0000; font-style: italic;">11 days
</span>      which-key-idle-secondary-delay 0.05)
</code></pre>
</div>

<p>
So that was just a small matter of personal preference, what's the
major reason at the heart of this polemic then? It is this: I believe
we should use computers for automation, to assist us in finding
information. Clearly <code>which-key-mode</code> has a different philosophy: it
merely displays all the key bindings under a prefix and then lets
humans do all the work! A human has to read the key bindings, possibly
paging through a couple of pages them. It feels ridiculously to be
sitting at a computer, a very powerful information retrieval machine,
equipped with a high bandwidth input device (namely: a keyboard) and
to read a bunch of boring text as if it were printed on a piece of
paper (or two or sometimes even three pieces of paper!)
</p>

<p>
Now, sometimes you <i>do</i> want to read all the key bindings under a
prefix, to find out or to refresh your memory about what's there. In
those cases I have no problem with <code>which-key</code>'s approach, but I find
that most often I'm looking for a specific key binding and I remember
a portion of the command name or maybe a bit of the binding (some
Emacs key bindings are long enough that I can remember them
partially but not completely!) When I'm looking for a specific
binding, I really want the computer to do the searching for me, that's
what the damn thing is for!
</p>

<p>
And now I'll tell you about the improved <code>which-key</code> I promised at the
start. It has all the paper-like functionality of <code>which-key</code>, but
additionally will help you search instead of patiently waiting while
you to do all the work yourself. This replacement is a function called
<code>embark-prefix-help-command</code> that comes with my <a href="https://github.com/oantolin/embark">Embark</a> package. To use
it simply <code>(setq prefix-help-command #'embark-prefix-help-command)</code>. The
<code>prefix-help-command</code> variable controls what happens when you press <code>C-h</code>
after typing a prefix. What <code>embark-prefix-help-command</code> does is prompt
you in the minibuffer, with completion, for a key-binding−command pair
under the current prefix. You can view your options or type some input
in the minibuffer to narrow the listing. It is best paired with a
minibuffer completion UI that automatically displays the current
completion candidates in real time as you type. (I discussed several
of these in another blog post: <a href="#my-quest-for-completion">My quest for completion</a>.) I recommend
<a href="https://github.com/minad/vertico">Vertico</a>, because it has an option to display completions in a grid,
which makes <code>embark-prefix-help-command</code> look a lot like <code>which-key</code>:
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(vertico-multiform-mode)
(add-to-list 'vertico-multiform-categories '(embark-keybinding grid))
</code></pre>
</div>

<p>
Here's what that looks like, for the same <code>C-x C-k</code> prefix as above:
</p>


<div id="org331d5d3" class="figure">
<p><img src="http://www.matem.unam.mx/~omar/files/embark-prefix-help-command-all.png" alt="embark-prefix-help-command-all.png" />
</p>
</div>

<p>
You could use this just like <code>which-key</code>, reading all the commands and
key bindings; Vertico even lets you use <code>C-v</code> and <code>M-v</code> to page through
the results (which I find slightly more comfortable than the default
in <code>which-key</code> of <code>C-h n</code> and <code>C-h p</code>). But you can also use the minibuffer
input to narrow the options. This works best if you have a completion
style that lets you type a substring from anywhere inside a candidate
to match it. I recommend the <a href="https://github.com/oantolin/orderless">Orderless</a> completion style, or I wouldn't
have written it, but the built-in <code>substring</code> completion style works
too. Say I was trying to remember a key binding for some command that
deals with keyboard macro counters ―see <code>(info "(emacs) Keyboard Macro
Counter")</code> if you haven't heard of these. Then you just type "cou" and
get this:
</p>


<div id="orgfe9b1f3" class="figure">
<p><img src="http://www.matem.unam.mx/~omar/files/embark-prefix-help-command-narrowed.png" alt="embark-prefix-help-command-narrowed.png" />
</p>
</div>

<p>
You can also narrow by a part of the key binding rather than the
command name. For example, I'm writing this blog post in org-mode and
have inline images displayed, but when you add a new one that one is
not displayed automatically. I could toggle the display of inline
images off and on again with <code>C-c C-x C-v</code>, but I remembered there was a
key binding for that, under the same <code>C-c C-x</code> prefix that involved <code>v</code>
with some other modifiers, so I typed <code>C-c C-x C-h</code> and then "-v" and
saw that <code>C-M-v</code> was the rest of the binding I was looking for.
</p>

<p>
This UI is very flexible: besides the narrowing via completion, you
can do lots of other things. You can can navigate with <code>C-n</code>, <code>C-p</code> or the
arrow keys among the completion candidates, press <code>RET</code> on a command to
run it, and you have the full power of Embark: say you have <code>embark-act</code>
bound to <code>C-.</code>, then you can press <code>C-. h</code> when a candidate is displayed
to show its documentation, or <code>C-. d</code> to go to its definition, or <code>C-. w</code>
to copy the command name to the kill-ring. Or say you want to explore
some subset of the commands more in depth, you can narrow to the
subset you want and run <code>embark-export</code> (with <code>C-. E</code>) to get a nice
<code>apropos-mode</code> buffer with a summary of those functions, like this one:
</p>


<div id="orgbcd8b36" class="figure">
<p><img src="http://www.matem.unam.mx/~omar/files/embark-prefix-help-command-apropos.png" alt="embark-prefix-help-command-apropos.png" />
</p>
</div>

<p>
Or say, you wanted a little table of those keyboard macro counter
commands and their key bindings. Instead of <code>embark-export</code> you'd use
<code>embark-collect</code> to get this buffer:
</p>


<div id="org0873b3b" class="figure">
<p><img src="http://www.matem.unam.mx/~omar/files/embark-prefix-help-command-collect.png" alt="embark-prefix-help-command-collect.png" />
</p>
</div>

<p>
From there I copied the first two columns as a rectangle, plopped them
into this org-mode buffer, added a few pipe symbols (using
<code>string-rectangle</code>), and a header, to get this table:
</p>

<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">


<colgroup>
<col  class="org-left" />

<col  class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Key</th>
<th scope="col" class="org-left">Command</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">C-a</td>
<td class="org-left">kmacro-add-counter</td>
</tr>

<tr>
<td class="org-left">TAB</td>
<td class="org-left">kmacro-insert-counter</td>
</tr>

<tr>
<td class="org-left">C-c</td>
<td class="org-left">kmacro-set-counter</td>
</tr>

<tr>
<td class="org-left">C-q &gt;</td>
<td class="org-left">kmacro-quit-counter-greater</td>
</tr>

<tr>
<td class="org-left">C-q &lt;</td>
<td class="org-left">kmacro-quit-counter-less</td>
</tr>

<tr>
<td class="org-left">C-q =</td>
<td class="org-left">kmacro-quit-counter-equal</td>
</tr>

<tr>
<td class="org-left">C-r s</td>
<td class="org-left">kmacro-reg-save-counter</td>
</tr>

<tr>
<td class="org-left">C-r l</td>
<td class="org-left">kmacro-reg-load-counter</td>
</tr>

<tr>
<td class="org-left">C-r a &gt;</td>
<td class="org-left">kmacro-reg-add-counter-greater</td>
</tr>

<tr>
<td class="org-left">C-r a &lt;</td>
<td class="org-left">kmacro-reg-add-counter-less</td>
</tr>

<tr>
<td class="org-left">C-r a =</td>
<td class="org-left">kmacro-reg-add-counter-equal</td>
</tr>
</tbody>
</table>

<p>
I hope this taste of the flexibility of <code>embark-prefix-help-command</code>
whets your appetite for more. 
</p>
]]></description>
</item>
<item>
<title>Emacs keymaps can have helpful and even dynamic prompts</title>
<link>http://www.matem.unam.mx/~omar/apropos-emacs.html#emacs-keymaps-can-have-prompts</link>
<author>omar@im.unam.mx (Omar Antolín Camarena)</author>
<guid isPermaLink="false">http://www.matem.unam.mx/~omar/apropos-emacs.html#emacs-keymaps-can-have-prompts</guid>
<pubDate>Thu, 03 Jul 2025 12:08:00 -0600</pubDate>

<description><![CDATA[<p>
<i>Published: [2025-07-03 Thu]. Comments <a href="https://mathstodon.xyz/@oantolin/114790627152642356">on Mastodon</a>.</i>
</p>

<p>
Nowadays <code>M-o</code> is unbound in Emacs by default, but it used to be used
for changing fonts in enriched text mode buffers. Enriched text is
what I consider an obscure format that Emacs supports pretty well for
some reason. I think rms had hopes of basing some Emacs word
processing functionality on enriched text, but I'm a little hazy on
the history ―which I'd love more knowledgeable people to educate me
on. Enriched text (not to be confused with Microsoft's Rich Text
Format) is the MIME text/enriched type defined by <a href="https://www.rfc-editor.org/rfc/rfc1563.html">internet RFC 1563</a>.
In Emacs its supported by the built-in <code>enriched</code> library ―see
<code>(finder-commentary "enriched")</code>.
</p>

<p>
Now that <code>M-o</code> is unbound by default, I recommend binding it to
<code>other-window</code> and turning off <code>repeat-mode</code> for that command with <code>(put
'other-window 'repeat-map nil)</code> so you can switch to another window and
type a word starting with "o" without trouble ―therwise you wind up
with an o-less word in the next window! In fact, I already used that
binding back when <code>M-o</code> was used for enriched text fonts.
</p>

<p>
But enough rambling, the reason I'm talking about this is that back
when <code>M-o</code> was bound to <code>facemenu-keymap</code>, pressing it would show this
message in the echo area:
</p>

<blockquote>
<p>
Set face: default, bold, italic, l = bold-italic, underline, Other...
</p>
</blockquote>

<p>
That's right: <code>M-o</code> was bound not to a command, but to a keymap, and
pressing it would show a message in the echo area!
</p>

<p>
One day redditor sebhoagie, asked <a href="https://www.reddit.com/r/emacs/comments/ch016m/how_to_tell_if_a_keymap_is_active/">how to display a dynamic message
when a keymap is active</a>, and I had that curiosity about <code>M-o</code> filed away
in my brain. I didn't know what exactly <code>M-o</code> was bound to at that point
in time, but I did now it was a keymap, because I had attempted to use
<code>C-h c M-o</code> only to have <code>describe-key-briefly</code> wait for more input. So I
set out to find out how that keymap did its magic. I ran <code>emacs -q</code>,
found out what <code>M-o</code> was bound to by default (recall that I was using it
for <code>other-window</code>), and here's the result (this is mostly what I wrote
on reddit back then, with the code modernized a bit):
</p>

<p>
You can add a prompt for the prefix keymap when you create it, and
also prompts for the individual keys bound in the keymap! For example,
the following code defines a keymap for package-related operations:
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span style="color: #0031a9; font-weight: bold;">defvar-keymap</span> pkg-ops-map
  <span style="color: #721045; font-weight: bold;">:name</span> <span style="color: #00598b;">"Packages"</span>
  <span style="color: #00598b;">"h"</span> '(<span style="color: #00598b;">"describe"</span> . describe-package)
  <span style="color: #00598b;">"r"</span> '(<span style="color: #00598b;">"reinstall"</span> . package-reinstall)
  <span style="color: #00598b;">"a"</span> '(<span style="color: #00598b;">"autoremove"</span> . package-autoremove)
  <span style="color: #00598b;">"d"</span> '(<span style="color: #00598b;">"delete"</span> . package-delete)
  <span style="color: #00598b;">"i"</span> '(<span style="color: #00598b;">"install"</span> . package-install)
  <span style="color: #00598b;">"l"</span> '(<span style="color: #00598b;">"list"</span> . list-packages))

(keymap-global-set <span style="color: #00598b;">"C-c p"</span> pkg-ops-map)
</code></pre>
</div>

<p>
(Here I'm using the recent family of commands, macros and functions
for dealing with keymaps, <code>keymap-set</code> and friends from <code>keymap-el</code>, which
only accept the key description strings that <code>kbd</code> uses; I recommend
these above the older <code>define-key</code> and friends.)
</p>

<p>
Now, as soon as you press <code>C-c p</code> the following message appears in the
echo area:
</p>

<blockquote>
<p>
Packages: list, install, delete, autoremove, reinstall, h = describe
</p>
</blockquote>

<p>
Notice that Emacs cleverly noticed that for the key <code>h</code> you gave the
prompt "describe", which does not start with <code>h</code>, so it actually prints
<code>h = describe</code>. The other prompts do start with the letter they are
bound to, so Emacs just lists the prompt you gave.
</p>

<p>
Of course, if you don't give a prompt for a binding, it's not
mentioned in the overall prompt for the keymap, but the key is still
bound. For example, if you replace <code>'("reinstall" . package-reinstall)</code>
with a simple <code>'package-reinstall</code> in the above code, then the prompt
will change to:
</p>

<blockquote>
<p>
Packages: list, install, delete, autoremove, h = describe
</p>
</blockquote>

<p>
but <code>r</code> will still be bound to <code>reinstall-package</code>.
</p>

<p>
Now, sebhoagie said that they had an application in mind for which
they wanted the prompt to change dynamically, so this trick wasn't
good enough. And I remember thinking: "Emacs Lisp is super imperative,
I bet keymaps are mutable!". I was right and as a proof of concept I
cooked up this little example:
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span style="color: #0031a9; font-weight: bold;">defvar</span> <span style="color: #00603f;">count</span> 0)

(<span style="color: #0031a9; font-weight: bold;">defvar-keymap</span> counter-map
  <span style="color: #721045; font-weight: bold;">:name</span> <span style="color: #00598b;">"Dynamic counter!"</span>
  <span style="color: #00598b;">"i"</span> '(<span style="color: #00598b;">"increment"</span> . inc-counter)
  <span style="color: #00598b;">"r"</span> '(<span style="color: #00598b;">"reset"</span> . reset-counter))

(<span style="color: #0031a9; font-weight: bold;">defun</span> <span style="color: #602938;">update-counter-map-prompt</span> ()
  (rplaca (last counter-map) (format <span style="color: #00598b;">"Counter is at %d!"</span> count)))

(<span style="color: #0031a9; font-weight: bold;">defun</span> <span style="color: #602938;">inc-counter</span> ()
  (<span style="color: #0031a9; font-weight: bold;">interactive</span>)
  (<span style="color: #0031a9; font-weight: bold;">setq</span> count (1+ count))
  (update-counter-map-prompt))

(<span style="color: #0031a9; font-weight: bold;">defun</span> <span style="color: #602938;">reset-counter</span> ()
  (<span style="color: #0031a9; font-weight: bold;">interactive</span>)
  (<span style="color: #0031a9; font-weight: bold;">setq</span> count 0)
  (update-counter-map-prompt))

(keymap-global-set <span style="color: #00598b;">"&lt;f5&gt;"</span> counter-map)
</code></pre>
</div>

<p>
After running that code, try <code>&lt;f5&gt; i</code> a few times to watch the counter
increment or <code>&lt;f5&gt; r</code> to reset it back to zero.
</p>

<p>
If you are a keymap description you might think you are set for life and
just kick back and relax, but you are as <code>rplaca</code>-ble as anyone else.
</p>
]]></description>
</item>
<item>
<title>My quest for completion</title>
<link>http://www.matem.unam.mx/~omar/apropos-emacs.html#my-quest-for-completion</link>
<author>omar@im.unam.mx (Omar Antolín Camarena)</author>
<guid isPermaLink="false">http://www.matem.unam.mx/~omar/apropos-emacs.html#my-quest-for-completion</guid>
<pubDate>Tue, 01 Jul 2025 14:49:00 -0600</pubDate>

<description><![CDATA[<p>
<i>Published: [2025-07-01 Tue]. Comments <a href="https://mathstodon.xyz/@oantolin/114779994118160925">on Mastodon</a></i>.
</p>

<p>
This is the entry I would have written for the "Take Two"-themed Emacs
carnival if it had taken me less than a month to decide to
participate. It's about all the myriad minibuffer completion UIs I've
been through as an Emacs user, and is quite long because I've tried so
many!
</p>

<p>
Just to make sure we're on the same page: Emacs commands prompt for
user input in the minibuffer and offer <i>completion</i>, which means some
sort of assistance typing sensible inputs. There are many possible
user interfaces for this in Emacs and I've tried many but all of them
(By the way, this is a constant in my Emacs usage: I try many but not
all of the options, since there are always too many. For example, of
the built-in ways to list buffers I've used <code>switch-to-buffer</code>, <code>ibuffer</code>,
<code>electric-buffer-list</code> and several third party options ―I currently
use <code>consult-buffer</code> from the Consult package― but I've never tried
the built-in <code>bs-show</code>, for example. Similarly, of the built-ins I've
only used GNUS to read email and RSS feeds, but never tried Rmail for
email or NewsTicker for RSS; let alone trying all third party options
―I did use mu4e for email for a bit and elfeed for RSS feeds!)
</p>

<p>
Just so this doesn't take forever to write, I will write it all from
memory, and let people correct me on details I get wrong ―it's only
fair since I do that to other people all the freaking time (it's a
wonder I have any friends). This list attempts to be in chronological
order of my usage, but I'm sure I'm getting some of this slightly
wrong (and fortunately no-one is likely to be able to call me out
about errors in the ordering of my personal usage of these UIs).
</p>
<div id="outline-container-org378a72e" class="outline-3">
<h3 id="org378a72e">Default completion</h3>
<div class="outline-text-3" id="text-org378a72e">
<p>
In my early days as an Emacs user I simply used the default completion
UI. This UI doesn't not show the completion candidates all the time.
If all the candidates have the next bit of text in common, pressing
TAB inserts it into the minibuffer (people call this TAB completion).
I've always found this funny since it makes <b>zero</b> progress towards
choosing a single completion candidate: it only inserts as much text
as will <b>not</b> narrow down things at all! But people like it for some
reason, I guess as visual feedback that what you thought the
completion candidates had in common they really do have in common. (To
be fair you can configure <code>completion-cycle-threshold</code> to have TAB cycle
among candidates when there aren't many left.)
</p>

<p>
Pressing TAB a second time will pop up the <code>*Completions*</code> buffer, which
shows a list of all completion candidates. From there you can click on
a candidates, navigate to it and press RET, or just type some more and
press TAB again to get an updated candidate list.
</p>

<p>
Don't knock the default completion UI. It is functional, powerful and
perfectly usable out of the box. But most people want to see how the
available candidates change automatically as you type. The other UIs I
tried all have that feature in common; they also all have a notion of
the "current completion candidate", and there is a way to select that
current candidate without finishing typing it ―usually but not
always this done simply by pressing RET.
</p>
</div>
</div>
<div id="outline-container-org3a6d2a7" class="outline-3">
<h3 id="org3a6d2a7">Ido</h3>
<div class="outline-text-3" id="text-org3a6d2a7">
<p>
Ido also comes with Emacs and is pretty funky. For one thing it
doesn't take over all minibuffer completion services, it only provides
special versions of certain commands, mainly to open files and switch
buffers. Those commands also enable some additional key bindings while
you are using the commands: while opening a file you can press a key
to delete a file, or while switching buffers you can press a key to
kill a buffer. This sort of thing is called "acting on a completion
candidate", and <a href="https://github.com/oantolin/embark">boy do I like it</a> ―more about this later. Ido uses
fuzzy completion, where characters only have to appear in order in a
completion candidate, not necessarily consecutively; for example <code>epnf</code>
matches <code>eww-open-file</code>.
</p>

<p>
If you like Ido but want to use it for all minibuffer completion there
are some options: there's the <a href="https://github.com/DarwinAwardWinner/ido-completing-read-plus">ido-completing-read+</a> package and the
built-in <code>fido-mode</code>. I don't particularly like fuzzy matching since it
feels inefficient to me, there are always two many matches for my
taste.
</p>
</div>
</div>
<div id="outline-container-orge951133" class="outline-3">
<h3 id="orge951133">Helm</h3>
<div class="outline-text-3" id="text-orge951133">
<p>
Helm is a comprehensive package that not only takes over all
minibuffer completion duties but comes with many commands that take
advantage of Helm's additional features. It's big and brash and
opinionated. I used it for many months and was quite happy with it. I
particularly liked that the Helm commands came with many actions you
could perform on the completion candidates. I didn't much like its
default aesthetics or its long load time (although since you only
incur that once per session it doesn't really matter). One thing I
didn't like much is that somehow it didn't seem to blend in very well
with the rest of my Emacs experience. For example, only commands
written specially to use Helm had actions for the completion
candidates, and the actions had to be implemented in a particular way,
you couldn't use any old Emacs command as an action. But all in all
Helm is great, an impressive piece of software that sprouted its own
mini-ecosystem of related packages.
</p>
</div>
</div>
<div id="outline-container-orge884195" class="outline-3">
<h3 id="orge884195">Ivy</h3>
<div class="outline-text-3" id="text-orge884195">
<p>
After Helm I used Ivy and its companion Swiper and Counsel packages
for a while. It felt pretty similar to using Helm to me, except I
liked the default look of it better (which is not to say you couldn't
easily configure the visual aspects of Helm). It also had a notion of
actions, but similarly to Helm, you needed to write them specially for
each command. I think it was less batteries-included than Helm, for
example I have a vague recollection of <code>counsel-find-file</code>, its
substitute for <code>find-file</code>, not coming with actions to rename or copy
files, which I wrote in my own configuration. It's then that it
started to bother me that I couldn't simply say "I want the Emacs
commands <code>rename-file</code> and <code>copy-file</code> as actions", I was forced to write
little wrappers for them. Like Helm, I think the Ivy/Swiper/Counsel
family is great software and was a happy user. I did however, as I did
with Helm, that it reinvented the wheel too much and that something
like it would be possible that took more advantage of existing Emacs
APIs and functions.
</p>
</div>
</div>
<div id="outline-container-orgf18259c" class="outline-3">
<h3 id="orgf18259c">Icomplete</h3>
<div class="outline-text-3" id="text-orgf18259c">
<p>
This is another built-in option, which I think I only started using
after having used Helm and Ivy. I used it for a quite a while and
still think it is perfectly workable. One thing I like about it is
that, like the default completion UI, it only concerns itself with
displaying the completion candidates and leaves the important matter
of which candidates are considered to match the minibuffer input to
the current <i>completion styles</i>. There is no formal notion in Emacs of a
"well-behaved" completion UI, but in my head certainly such a UI
should limit itself to showing you the candidates and leave the user
to configure completion styles separately. This what I dislike about
<code>fido-mode</code>: it ignores your completion style configuration and makes
you use the <code>flex</code> completion style instead (you can change this but it
requires being sneaky, not simply setting <code>completion-styles</code>).
</p>

<p>
One difference between Icomplete and Helm or Ivy, is that it displays
the completion candidates in a compact horizontal list like Ido,
instead of one per line, like Helm or Ivy. When I was an Icomplete
user, I even wrote a package called <a href="https://github.com/oantolin/icomplete-vertical">icomplete-vertical</a> that would
configure Icomplete to display the candidates vertically, one per
line. Nowadays there is also a built-in package of the same name which
I did not write, nor does it use my code. I remember thinking the
built-in package had a bug mine lacked, triggered when you switched
from horizontal to vertical during a minibuffer completion session,
but I couldn't reproduce it now so either they fixed it, or I couldn't
remember exactly what the bug was, or my memory is playing tricks on
me.
</p>
</div>
</div>
<div id="outline-container-orgf005418" class="outline-3">
<h3 id="orgf005418">live-completions</h3>
<div class="outline-text-3" id="text-orgf005418">
<p>
The mention of icomplete-vertical above is the start of an
embarrassing parade of completion UIs I wrote myself, for myself and
which I don't think more than a handful people ever used. What marred
all of my feeble attempts, other than icomplete-vertical which is just
some configuration code on top of icomplete, was a distinct lack of
speed. The idea of these incremental, automatic completion UIs is to
show you how the candidate list changes in real time, but most of mine
struggled to do this fast enough.
</p>

<p>
My <a href="https://github.com/oantolin/live-completions">live-completions</a> package had a very simple idea: pop up the
<code>*Completions*</code> buffer that the default UI uses and just update it after
every key press. It let you format the completions in either a grid or
a single column, back before the default UI had the single column
view.
</p>

<p>
I think I used this for quite a while though it wasn't very good. I
believe that by the time I wrote this, I already had an initial
version of Embark that took care of acting on completion candidates
solving all of the complaints I had about actions in Ido, Helm or Ivy:
Embark lets you use any Emacs command directly as an action, there is
no need to write wrappers over existing commands; it endows every
single command that has a minibuffer prompt with actions on its
candidates, commands do not have to be written specially with Embark
in mind to acquire actions.
</p>
</div>
</div>
<div id="outline-container-org3a2a10f" class="outline-3">
<h3 id="org3a2a10f">grille</h3>
<div class="outline-text-3" id="text-org3a2a10f">
<p>
Another bad completion UI I wrote. Hey, <a href="https://github.com/oantolin/emacs-config/blob/master/experiments/grille.el">at least it's small</a>. I don't
think I used this for very long, maybe a couple of weeks. It's called
grille because it displays completions in a grid. I have nothing  else
to say about it.
</p>
</div>
</div>
<div id="outline-container-orgc817d7d" class="outline-3">
<h3 id="orgc817d7d">embark-completions</h3>
<div class="outline-text-3" id="text-orgc817d7d">
<p>
For a while Embark included its own completions UI! This is obviously
a bad idea, which I only did because it was easy, since Embark had
grown to have almost all the components necessary for this. It was
slow, but other than that I found it surprisingly good. It was
certainly featureful: it displayed the completions either one per line
or in a grid, the grid optionally with zebra stripes to guide the eye.
I stubbornly kept using it until I dropped it for Vertico and finally
removed it from Embark.
</p>
</div>
</div>
<div id="outline-container-orgc081360" class="outline-3">
<h3 id="orgc081360">Vertico</h3>
<div class="outline-text-3" id="text-orgc081360">
<p>
The excellent Vertico package is what I use now as a completion UI.
The author, Daniel Mendler, and I have long worked together on a suite
of packages that provide a full completion experience for Emacs. I
wanted to switch from embark-completions to Vertico but held out until
Daniel added a grid display to Vertico. In retrospect this was silly
on my part, but I believe my stubbornness might have helped motivate
Daniel to add the grid feature. Of this suite of packages, Daniel
wrote Vertico, Corfu, Cape; I wrote Embark and Orderless (the latter
of which we now co-maintain); and we wrote Marginalia together after
noticing we were both writing something like it.
</p>

<dl class="org-dl">
<dt>Vertico</dt><dd>a highly flexible completion UI, that can display
completions one per line or in a grid, in the minibuffer or in a
dedicated buffer.</dd>
<dt>Orderless</dt><dd>a highly configurable completion style, whose main
feature is matching space-separated bits of the input in any order
against the completion candidates; so <code>op eww</code> matches <code>eww-open-file</code>.</dd>
<dt>Embark</dt><dd>lets you use any Emacs command as an action on any
minibuffer completion candidate or on a thing at point in a non-mini
buffer; it also comes with an extensive default configuration
assigning convenient keybindings to the most commonly used actions
(but you can always <code>M-x</code> to use whatever command you want as an
action!)</dd>
<dt>Marginalia</dt><dd>provides extra information about completion candidates
of common types, most completion UIs that display candidates as one
per line will shows this extra information to the right of the candidate.</dd>
<dt>Corfu</dt><dd>this is a completion UI for completion-at-point, which I
haven't talked about here at all ―it is the type of completion
that you get when writing code in a buffer, for example. Again here
I stubbornly held out a long time using my own contraption
(<code>consult-completion-in-region</code>, which I contributed to consult).</dd>
<dt>Cape</dt><dd>a suite of completion-at-point functions; again I stubbornly
held out using an embark-based substitute for this for a long time
―I'm starting to notice an unflattering pattern.</dd>
</dl>
</div>
</div>
<div id="outline-container-orgade30ac" class="outline-3">
<h3 id="orgade30ac">Selectrum and MCT</h3>
<div class="outline-text-3" id="text-orgade30ac">
<p>
I already finished listing the completion UIs that I actually used for
a period of time, but there are a couple of others I tried and
probably some I did not try (maybe <a href="https://github.com/manateelazycat/snails">snails</a>, though I'm not exactly sure
what it is, since I've only every briefly skimmed its README). I tried
Selectrum once and, to my discredit, only complained about some minor
issues with it on reddit. At least I'm focused thematically in my
complaints: I thought it wasn't Emacsy enough, that it disrespected
some Emacs variables it could easily respect. Well, that, and there
something I didn't like about its <code>completing-read-multiple</code> experience
(I think it was that you couldn't easily see what you had already
selected). I never used Prot's MCT package extensively, but I would
call it similar in idea to my live-completions package, and would hope
Prot does not disagree with this characterization. It somehow seemed
smoother than my live-completions, probably because Prot had more
patience tweaking the experience than I did.
</p>
</div>
</div>
]]></description>
</item>
<item>
<title>Welcome to ~M-x apropos Emacs~</title>
<link>http://www.matem.unam.mx/~omar/apropos-emacs.html#welcome-to-M-x-apropos-Emacs</link>
<author>omar@im.unam.mx (Omar Antolín Camarena)</author>
<guid isPermaLink="false">http://www.matem.unam.mx/~omar/apropos-emacs.html#welcome-to-M-x-apropos-Emacs</guid>
<pubDate>Tue, 01 Jul 2025 13:00:00 -0600</pubDate>

<description><![CDATA[<p>
<i>Published: [2025-07-01 Tue]</i>.
</p>

<p>
Recently <a href="https://christiantietze.de/posts/2025/06/emacs-carnival-2025-06-take-two/">Christian Tietze called for Emacs blog posts</a> with the topic
"Take Two", meaning things that took two or more tries to get right.
He also said:
</p>
<blockquote>
<p>
Don’t have a blog, yet?
</p>

<p>
Well, just start one already! :)
</p>

<p>
It’s the future of the internet!
</p>
</blockquote>

<p>
I mulled over this the whole month and finally decided to start a blog
about Emacs just in time to miss that first round of the Emacs
carnival! (I'm likely to miss deadlines like that again in the
future.)
</p>

<p>
Now, about twenty years ago, when blogs did actually seem like the
future of the internet, I had one on a hosted service. I think I may
have started on Blogspot, but then <a href="https://notandiario.wordpress.com/">moved to Wordpress.com</a>. It was a
personal blog about whatever random topic I wanted to write about. I
did not write very frequently on that blog, and am unlikely to write
often here either, although maybe constraining the topic to Emacs
might inspire me more than having no constraints did.
</p>

<p>
I was already an Emacs user back then, but I wasn't as gung-ho about
it as now, and back then I meekly accepted Wordpress making all sorts
of decisions for me, which seems cowardly today; so I definitely want
a more Emacsy way to write this new blog. I figure all a blog needs is
a publicly accessible web page and a publicly accessible RSS feed. An
important optional component is a system for comments. So, to do the
easiest thing possible, I will write my blog in a single Org file (for
now, I'll manually paginate if it turns out I do keep it up!), use
<a href="https://github.com/benedicthw/ox-rss">ox-rss</a> to create <a href="https://www.matem.unam.mx/~omar/apropos-emacs.xml">an RSS feed</a>, and for comments I'll just use Mastodon.
</p>

<p>
Since I threw this together in about ten minutes, I'm sure there will
be bugs. I probably don't have permalinks correct at all.
</p>

<script type="text/javascript" src="visibility-toggle.js"></script>

<script type="text/javascript">
(function() {
    const posts = document.getElementsByClassName("outline-2");
    for (var i = 0; i < posts.length; i++) {
        installVisibilityToggler(posts[i].children);
    }
    const showhash = function(_event) {
        if (window.location.hash) {
            document.querySelector(window.location.hash+' input[type="button"]').
                onclick('show');
        }
    }
    window.addEventListener('hashchange', showhash);
    window.addEventListener('load', showhash);
})();
</script>
]]></description>
</item>
</channel>
</rss>
