<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://emacsredux.com/atom.xml" rel="self" type="application/atom+xml" /><link href="https://emacsredux.com/" rel="alternate" type="text/html" /><updated>2026-09-03T09:04:01+00:00</updated><id>https://emacsredux.com/atom.xml</id><title type="html">Emacs Redux</title><subtitle>Return to the Essence of Text Editing</subtitle><author><name>Bozhidar Batsov</name></author><entry><title type="html">Working with Git Worktrees in Magit</title><link href="https://emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit/" rel="alternate" type="text/html" title="Working with Git Worktrees in Magit" /><published>2026-09-02T14:28:00+00:00</published><updated>2026-09-02T14:28:00+00:00</updated><id>https://emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit</id><content type="html" xml:base="https://emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit/"><![CDATA[<p>I’ll admit that until fairly recently I had no idea git worktrees existed.
They’ve been part of git for a decade<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup> and I never once needed them. Feature
branches did the job just fine - create a branch, do the work, merge it, delete
it, and start over.</p>

<p>What finally introduced me to worktrees was, of all things, AI coding agents.
Tools like Claude Code create a worktree for each task, so several agents (or
several sessions of the same agent) can work on the same repo in parallel
without stepping on each other - or on you. Suddenly my projects directory was
full of <code class="language-plaintext highlighter-rouge">cider-this</code> and <code class="language-plaintext highlighter-rouge">cider-that</code> siblings, and I figured I should
understand what’s actually going on there.</p>

<!--more-->

<h2 id="worktrees-vs-branches">Worktrees vs Branches</h2>

<p>A branch is just a movable pointer to a commit, and making one is basically
free. The catch is that a repository has a single working directory, so working
on two branches means switching that directory back and forth. You know the
routine: stash your half-done work (or commit it), check out the other branch,
do the thing, check out the first branch again, unstash. It works, but it’s
tedious, and it gets worse when the two branches leave your project in
different build states and every switch means recompiling half the world.</p>

<p>A worktree gives you an additional working directory attached to the same
repository:</p>

<pre><code class="language-shellsession">$ git worktree add ../cider-smart-targeting -b smart-form-targeting
</code></pre>

<p>Now <code class="language-plaintext highlighter-rouge">~/projects/cider-smart-targeting</code> is a full checkout of that branch, while
your main checkout stays exactly where it was. The object database, refs,
stashes and remotes are all shared - a worktree is not a clone, so fetching in
one is fetching in all, and creating one is nearly instant. Each worktree gets
its own <code class="language-plaintext highlighter-rouge">HEAD</code> and index, and git enforces one simple rule: a branch can only
be checked out in one worktree at a time.</p>

<p>When are they worth it? Whenever two things need to happen at the same time: a
long test run on one branch while you work on another, reviewing a PR without
disturbing your half-done work, or - the reason everyone is talking about them
these days - AI agents doing their thing in isolation. The price is pretty
modest: your working files exist on disk more than once, and anything that
isn’t tracked by git (dependencies, build caches, <code class="language-plaintext highlighter-rouge">node_modules</code> and friends)
has to be set up again in each worktree.</p>

<p>If branches have never felt limiting to you, that’s fine - they didn’t for me
either, for over a decade. Worktrees are one of those features you don’t miss
until your workflow changes.</p>

<h2 id="what-about-jujutsu">What About Jujutsu?</h2>

<p>While we’re on the topic of working copies - the most interesting thing
happening in version control right now is
<a href="https://jj-vcs.github.io/jj/">Jujutsu</a> (<code class="language-plaintext highlighter-rouge">jj</code>), a git-compatible VCS that makes
the problem worktrees solve mostly go away. In jj the working copy <em>is</em> a
commit, snapshotted automatically as you work. There’s no staging area and no
stash, because there’s no uncommitted state that could be lost or get in the
way - switching contexts is always safe. It also has proper support for
parallel working directories (<code class="language-plaintext highlighter-rouge">jj workspace</code>), plus an operation log that makes
practically everything undoable. That last bit is part of why the AI agent
crowd has taken an interest in it too.</p>

<p>You can use jj on top of an existing git repository (they call this a colocated
repo), and your colleagues - and Magit - will keep seeing a normal git repo.
I’m still just an observer here, but it’s clearly a project to keep an eye on.</p>

<h2 id="worktrees-in-magit">Worktrees in Magit</h2>

<p>Back to Emacs land. Magit has had worktree support for years, hiding behind <code class="language-plaintext highlighter-rouge">Z</code>:</p>

<table>
  <thead>
    <tr>
      <th>Key</th>
      <th>Command</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">Z b</code></td>
      <td><code class="language-plaintext highlighter-rouge">magit-worktree-checkout</code></td>
      <td>Check out an existing branch in a new worktree</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">Z c</code></td>
      <td><code class="language-plaintext highlighter-rouge">magit-worktree-branch</code></td>
      <td>Create a new branch and worktree in one go</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">Z g</code></td>
      <td><code class="language-plaintext highlighter-rouge">magit-worktree-status</code></td>
      <td>Jump to another worktree’s status buffer</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">Z m</code></td>
      <td><code class="language-plaintext highlighter-rouge">magit-worktree-move</code></td>
      <td>Move a worktree</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">Z k</code></td>
      <td><code class="language-plaintext highlighter-rouge">magit-worktree-delete</code></td>
      <td>Delete a worktree</td>
    </tr>
  </tbody>
</table>

<p>The best part is that there’s nothing else to learn. Each worktree gets its own
Magit status buffer, and every Magit command operates on the worktree the
current buffer belongs to. <code class="language-plaintext highlighter-rouge">Z g</code> is the only switching mechanism you need, and
even that is just a shortcut for visiting another status buffer.</p>

<p>A few practical tips from my (admittedly recent) experience:</p>

<ul>
  <li>By default the status buffer doesn’t list your worktrees. Fix that with:</li>
</ul>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nv">magit-add-section-hook</span> <span class="ss">'magit-status-sections-hook</span>
                        <span class="nf">#'</span><span class="nv">magit-insert-worktrees</span>
                        <span class="no">nil</span> <span class="no">t</span><span class="p">)</span>
</code></pre></div></div>

<p>Now every status buffer shows all worktrees of the repo, and you can hit
  <code class="language-plaintext highlighter-rouge">RET</code> on any of them to jump there.</p>

<ul>
  <li>
    <p>Create worktrees as <em>siblings</em> of the main checkout with descriptive names
(<code class="language-plaintext highlighter-rouge">cider-smart-targeting</code> next to <code class="language-plaintext highlighter-rouge">cider</code>), not nested inside it - nesting
confuses <code class="language-plaintext highlighter-rouge">grep</code>, <code class="language-plaintext highlighter-rouge">find</code> and plenty of other tools.</p>
  </li>
  <li>
    <p>Magit’s branch selection annotates branches that are checked out in another
worktree with the worktree’s path, and refuses to check them out a second
time (that’s git’s rule, not Magit being difficult). If you ever wondered why
a branch “won’t check out”, that’s usually why.</p>
  </li>
  <li>
    <p>Each worktree is its own project as far as <code class="language-plaintext highlighter-rouge">project.el</code> (or Projectile) is
concerned, so project switching, per-project buffers and search all work
naturally.</p>
  </li>
  <li>
    <p>Anything that’s not tracked by git doesn’t come along for the ride. You’ll
have to install dependencies once per worktree and start with a cold build
cache. For Elisp that costs you nothing; for a big JVM or JS project it’s the
main downside of the whole approach.</p>
  </li>
  <li>
    <p>When you’re done with a worktree, delete it with <code class="language-plaintext highlighter-rouge">Z k</code> (or with
<code class="language-plaintext highlighter-rouge">git worktree remove</code> from the command line). If you just delete the
directory by hand, <code class="language-plaintext highlighter-rouge">git worktree prune</code> will clean up the leftover
bookkeeping.</p>
  </li>
</ul>

<h2 id="closing-thoughts">Closing Thoughts</h2>

<p>These days my workflow with agents usually looks like this: an agent does its
work in a worktree, I review the changes there in Magit (often while another
task is running in a second worktree), and the worktree goes away once the
branch is merged. Maybe one day I’ll find other uses for worktrees - we’ll see.</p>

<p>Are you using git worktrees - and did you discover them the same roundabout way
I did? I’d love to hear about it in the comments!</p>

<p>That’s all I have for you today. Keep hacking (in parallel)!</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1" role="doc-endnote">
      <p>They were introduced in git 2.5, released all the way back in July 2015. <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Bozhidar Batsov</name></author><category term="Magit" /><category term="Git" /><summary type="html"><![CDATA[I’ll admit that until fairly recently I had no idea git worktrees existed. They’ve been part of git for a decade1 and I never once needed them. Feature branches did the job just fine - create a branch, do the work, merge it, delete it, and start over. What finally introduced me to worktrees was, of all things, AI coding agents. Tools like Claude Code create a worktree for each task, so several agents (or several sessions of the same agent) can work on the same repo in parallel without stepping on each other - or on you. Suddenly my projects directory was full of cider-this and cider-that siblings, and I figured I should understand what’s actually going on there. They were introduced in git 2.5, released all the way back in July 2015. &#8617;]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://emacsredux.com/assets/og-image.png" /><media:content medium="image" url="https://emacsredux.com/assets/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Meet Utterson, my Jekyll blogging helper</title><link href="https://emacsredux.com/blog/2026/08/26/meet-utterson-my-jekyll-blogging-helper/" rel="alternate" type="text/html" title="Meet Utterson, my Jekyll blogging helper" /><published>2026-08-26T14:24:00+00:00</published><updated>2026-08-26T14:24:00+00:00</updated><id>https://emacsredux.com/blog/2026/08/26/meet-utterson-my-jekyll-blogging-helper</id><content type="html" xml:base="https://emacsredux.com/blog/2026/08/26/meet-utterson-my-jekyll-blogging-helper/"><![CDATA[<p>Back in 2019 I wrote about <a href="/blog/2019/05/21/dealing-with-jekyll-post-urls/">dealing with Jekyll post URLs</a>,
where I shared a tiny command that spared me from having to remember the exact
file name of every article I wanted to link to. That command has been in my config
ever since, and over the years it quietly grew a few siblings. Recently I finally
gathered them all in one place and turned them into a small package -
<a href="https://github.com/bbatsov/utterson">utterson</a>.</p>

<h2 id="the-common-jekyll-tasks">The common Jekyll tasks</h2>

<p>I guess anyone who blogs with Jekyll knows the drill. Jekyll is great and I have
no intention of switching, but a few of its conventions generate a steady trickle
of manual work:</p>

<ul>
  <li>posts live in <code class="language-plaintext highlighter-rouge">_posts</code> and their file names have to start with the publication
date, as in <code class="language-plaintext highlighter-rouge">2026-08-26-some-post.md</code></li>
  <li>every article needs a bit of YAML front matter at the top - a layout, a title,
a date, some tags</li>
  <li>linking to another post means using a Liquid tag that wants that date-prefixed
file name, which nobody remembers</li>
  <li>images and other assets need URLs relative to the site root, not to the article
you happen to be editing</li>
</ul>

<p>None of this is hard. All of it is annoying, and all of it is exactly the sort of
mechanical work an editor should be doing on your behalf. So over the years I
wrote a command for each chore, dropped it in my <code class="language-plaintext highlighter-rouge">init.el</code> and moved on with my
life.</p>

<h2 id="why-i-finally-cleaned-this-up">Why I finally cleaned this up</h2>

<p>The tipping point was the last command I added - promoting a draft to a post.</p>

<p>I write most articles in <code class="language-plaintext highlighter-rouge">_drafts</code>, where <code class="language-plaintext highlighter-rouge">jekyll serve --drafts</code> shows them but a
deploy doesn’t. Publishing one used to mean renaming the file by hand to add
today’s date, then editing the <code class="language-plaintext highlighter-rouge">date</code> in the front matter to match, then
convincing git that this was a rename rather than a delete plus a brand new file.
Three chances to get something wrong, and I certainly got it wrong more than once.</p>

<p>Once that was automated I took a look at what had accumulated in my config and
realized it wasn’t a bag of snippets anymore - it was a workflow. And since every
person blogging with Jekyll from Emacs deals with exactly the same chores, there
was no good reason to keep it to myself. So I spent an evening extracting the
lot, wrote some tests, and gave it a name.<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup></p>

<p>There are other Jekyll packages for Emacs, of course. Both
<a href="https://github.com/nibrahim/Hyde">hyde</a> and
<a href="https://github.com/masasam/emacs-easy-jekyll">easy-jekyll</a> aim to be something
like an IDE for your site, with dashboards, deployment and preview buffers. That’s
a perfectly reasonable thing to want, it’s just never been what I wanted. My site
lives in git, I deploy it with a push, and I’ve already got Magit and a browser.
All I ever wanted was for the bookkeeping to stop being my problem.</p>

<p>So <code class="language-plaintext highlighter-rouge">utterson</code> is deliberately small. It knows that a Jekyll site is a folder of
Markdown files with YAML front matter, and that’s about the extent of its
ambitions. Renames go through <code class="language-plaintext highlighter-rouge">vc</code>, so git records them as renames and the history
of an article follows it around. Nothing in there ever deploys anything.</p>

<h2 id="taking-it-for-a-spin">Taking it for a spin</h2>

<p>The package is not on MELPA (yet?), so for the time being it’s <code class="language-plaintext highlighter-rouge">package-vc</code>
territory:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nb">use-package</span> <span class="nv">utterson</span>
  <span class="ss">:vc</span> <span class="p">(</span><span class="ss">:url</span> <span class="s">"https://github.com/bbatsov/utterson"</span> <span class="ss">:rev</span> <span class="ss">:newest</span><span class="p">)</span>
  <span class="ss">:custom</span>
  <span class="c1">;; where to look for sites, when you invoke a command outside one</span>
  <span class="p">(</span><span class="nv">utterson-search-path</span> <span class="o">'</span><span class="p">(</span><span class="s">"~/projects/"</span><span class="p">))</span>
  <span class="ss">:config</span>
  <span class="c1">;; the commands live in a keymap that you bind wherever you please</span>
  <span class="p">(</span><span class="nv">keymap-set</span> <span class="nv">utterson-mode-map</span> <span class="s">"C-c j"</span> <span class="ss">'utterson-command-map</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">global-utterson-mode</span> <span class="mi">+1</span><span class="p">))</span>
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">global-utterson-mode</code> enables the minor mode in the buffers of any folder that
has a <code class="language-plaintext highlighter-rouge">_config.yml</code> in it, so the commands are around while you’re working on a
site and nowhere else.</p>

<p><code class="language-plaintext highlighter-rouge">C-c j p</code> starts a post. It asks for a title, offers a file name slug derived from
it (which you’re free to shorten right there, and I usually do), then asks for
tags, completing against every tag the site already uses. That last bit is how you
avoid ending up with both <code class="language-plaintext highlighter-rouge">Emacs</code> and <code class="language-plaintext highlighter-rouge">emacs</code> in your tag cloud. Finally it writes
the front matter, saves the file and leaves the cursor exactly where you’re about
to start writing:</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nn">---</span>
<span class="na">layout</span><span class="pi">:</span> <span class="s">post</span>
<span class="na">title</span><span class="pi">:</span> <span class="s">Meet Utterson, my Jekyll blogging helper</span>
<span class="na">date</span><span class="pi">:</span> <span class="s">2026-08-26 15:01 +0300</span>
<span class="na">tags</span><span class="pi">:</span>
<span class="pi">-</span> <span class="s">Jekyll</span>
<span class="pi">-</span> <span class="s">Blogs</span>
<span class="pi">-</span> <span class="s">Packages</span>
<span class="nn">---</span>
</code></pre></div></div>

<p>That block, as it happens, is the one this very article started with. Here’s the
whole thing in action:</p>

<p><img src="/assets/images/utterson-new-post.gif" alt="Creating a new post with utterson: the title prompt, the slug derived from it, tag completion, and the finished front matter" /></p>

<p><code class="language-plaintext highlighter-rouge">C-c j d</code> does the same in <code class="language-plaintext highlighter-rouge">_drafts</code> and <code class="language-plaintext highlighter-rouge">C-c j t</code> moves an article between the
two, dating it on the way in and staging the rename with git. <code class="language-plaintext highlighter-rouge">C-c j r</code> is for the
article you wrote a couple of weeks ago and never got around to publishing - it
sets the date to now and renames the file to match. Both of them take a prefix
argument if you’d rather type a date than accept the current time, which is how
you schedule something for next Monday morning.</p>

<p>Publishing a draft looks like this - notice that the file name, the <code class="language-plaintext highlighter-rouge">date</code> in the
front matter and git’s idea of what happened all stay in sync:</p>

<p><img src="/assets/images/utterson-publish-draft.gif" alt="Publishing a draft with utterson: the file is renamed with today's date, the front matter date is updated, and git records a rename" /></p>

<p>The linking commands are the descendants of that 2019 snippet, all grown up.
<code class="language-plaintext highlighter-rouge">C-c j u</code> inserts a <code class="language-plaintext highlighter-rouge">post_url</code> tag, completing over your posts newest first and
showing you each post’s title next to its file name, and <code class="language-plaintext highlighter-rouge">C-c j l</code> inserts the
entire Markdown link, already titled after the post it points to:</p>

<p><img src="/assets/images/utterson-insert-post-link.gif" alt="Inserting a link to another post: the completion list shows every post newest first, with its title next to the file name" /></p>

<p><code class="language-plaintext highlighter-rouge">C-c j i</code>
inserts an image, <code class="language-plaintext highlighter-rouge">C-c j I</code> copies a file into your images folder first (perfect
for a screenshot that’s still sitting on your desktop under a name like
<code class="language-plaintext highlighter-rouge">Screenshot 2026-08-26 at 15.01.12.png</code>), and <code class="language-plaintext highlighter-rouge">C-c j a</code> links to anything else
under <code class="language-plaintext highlighter-rouge">assets</code>. And <code class="language-plaintext highlighter-rouge">C-c j s</code> runs <code class="language-plaintext highlighter-rouge">jekyll serve</code> in a buffer, because sooner or
later you do want to look at the thing.</p>

<p><strong>Note:</strong> There’s a menu as well, in case you’d rather click your way around while
the keybindings are still settling in.</p>

<h2 id="epilogue">Epilogue</h2>

<p>It’s early days for the package, even though most of the code behind it has been
in daily use for years. If you blog with Jekyll from Emacs, I’d love to hear which
of your own little chores it doesn’t cover yet - that’s the fastest way for it to
get better.</p>

<p>And if you don’t blog with Jekyll - what does your setup look like? I’ve got the
feeling that quite a few of you are writing your posts in <code class="language-plaintext highlighter-rouge">org-mode</code> and I’m
always curious about the workflows people come up with.</p>

<p>That’s all I have for you today! Keep hacking!</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1" role="doc-endnote">
      <p>Gabriel John Utterson is Doctor Jekyll’s loyal friend and lawyer - the man
who keeps his affairs in order. Naming things is hard, but every now and then
you get lucky. <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Bozhidar Batsov</name></author><category term="Jekyll" /><category term="Blogs" /><category term="Packages" /><summary type="html"><![CDATA[Back in 2019 I wrote about dealing with Jekyll post URLs, where I shared a tiny command that spared me from having to remember the exact file name of every article I wanted to link to. That command has been in my config ever since, and over the years it quietly grew a few siblings. Recently I finally gathered them all in one place and turned them into a small package - utterson. The common Jekyll tasks I guess anyone who blogs with Jekyll knows the drill. Jekyll is great and I have no intention of switching, but a few of its conventions generate a steady trickle of manual work: posts live in _posts and their file names have to start with the publication date, as in 2026-08-26-some-post.md every article needs a bit of YAML front matter at the top - a layout, a title, a date, some tags linking to another post means using a Liquid tag that wants that date-prefixed file name, which nobody remembers images and other assets need URLs relative to the site root, not to the article you happen to be editing None of this is hard. All of it is annoying, and all of it is exactly the sort of mechanical work an editor should be doing on your behalf. So over the years I wrote a command for each chore, dropped it in my init.el and moved on with my life. Why I finally cleaned this up The tipping point was the last command I added - promoting a draft to a post. I write most articles in _drafts, where jekyll serve --drafts shows them but a deploy doesn’t. Publishing one used to mean renaming the file by hand to add today’s date, then editing the date in the front matter to match, then convincing git that this was a rename rather than a delete plus a brand new file. Three chances to get something wrong, and I certainly got it wrong more than once. Once that was automated I took a look at what had accumulated in my config and realized it wasn’t a bag of snippets anymore - it was a workflow. And since every person blogging with Jekyll from Emacs deals with exactly the same chores, there was no good reason to keep it to myself. So I spent an evening extracting the lot, wrote some tests, and gave it a name.1 There are other Jekyll packages for Emacs, of course. Both hyde and easy-jekyll aim to be something like an IDE for your site, with dashboards, deployment and preview buffers. That’s a perfectly reasonable thing to want, it’s just never been what I wanted. My site lives in git, I deploy it with a push, and I’ve already got Magit and a browser. All I ever wanted was for the bookkeeping to stop being my problem. So utterson is deliberately small. It knows that a Jekyll site is a folder of Markdown files with YAML front matter, and that’s about the extent of its ambitions. Renames go through vc, so git records them as renames and the history of an article follows it around. Nothing in there ever deploys anything. Taking it for a spin The package is not on MELPA (yet?), so for the time being it’s package-vc territory: (use-package utterson :vc (:url "https://github.com/bbatsov/utterson" :rev :newest) :custom ;; where to look for sites, when you invoke a command outside one (utterson-search-path '("~/projects/")) :config ;; the commands live in a keymap that you bind wherever you please (keymap-set utterson-mode-map "C-c j" 'utterson-command-map) (global-utterson-mode +1)) global-utterson-mode enables the minor mode in the buffers of any folder that has a _config.yml in it, so the commands are around while you’re working on a site and nowhere else. C-c j p starts a post. It asks for a title, offers a file name slug derived from it (which you’re free to shorten right there, and I usually do), then asks for tags, completing against every tag the site already uses. That last bit is how you avoid ending up with both Emacs and emacs in your tag cloud. Finally it writes the front matter, saves the file and leaves the cursor exactly where you’re about to start writing: --- layout: post title: Meet Utterson, my Jekyll blogging helper date: 2026-08-26 15:01 +0300 tags: - Jekyll - Blogs - Packages --- That block, as it happens, is the one this very article started with. Here’s the whole thing in action: C-c j d does the same in _drafts and C-c j t moves an article between the two, dating it on the way in and staging the rename with git. C-c j r is for the article you wrote a couple of weeks ago and never got around to publishing - it sets the date to now and renames the file to match. Both of them take a prefix argument if you’d rather type a date than accept the current time, which is how you schedule something for next Monday morning. Publishing a draft looks like this - notice that the file name, the date in the front matter and git’s idea of what happened all stay in sync: The linking commands are the descendants of that 2019 snippet, all grown up. C-c j u inserts a post_url tag, completing over your posts newest first and showing you each post’s title next to its file name, and C-c j l inserts the entire Markdown link, already titled after the post it points to: C-c j i inserts an image, C-c j I copies a file into your images folder first (perfect for a screenshot that’s still sitting on your desktop under a name like Screenshot 2026-08-26 at 15.01.12.png), and C-c j a links to anything else under assets. And C-c j s runs jekyll serve in a buffer, because sooner or later you do want to look at the thing. Note: There’s a menu as well, in case you’d rather click your way around while the keybindings are still settling in. Epilogue It’s early days for the package, even though most of the code behind it has been in daily use for years. If you blog with Jekyll from Emacs, I’d love to hear which of your own little chores it doesn’t cover yet - that’s the fastest way for it to get better. And if you don’t blog with Jekyll - what does your setup look like? I’ve got the feeling that quite a few of you are writing your posts in org-mode and I’m always curious about the workflows people come up with. That’s all I have for you today! Keep hacking! Gabriel John Utterson is Doctor Jekyll’s loyal friend and lawyer - the man who keeps his affairs in order. Naming things is hard, but every now and then you get lucky. &#8617;]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://emacsredux.com/assets/og-image.png" /><media:content medium="image" url="https://emacsredux.com/assets/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Flycheck 38: Might &amp;amp; Magic</title><link href="https://emacsredux.com/blog/2026/07/29/flycheck-38/" rel="alternate" type="text/html" title="Flycheck 38: Might &amp;amp; Magic" /><published>2026-07-29T09:00:00+00:00</published><updated>2026-07-29T09:00:00+00:00</updated><id>https://emacsredux.com/blog/2026/07/29/flycheck-38</id><content type="html" xml:base="https://emacsredux.com/blog/2026/07/29/flycheck-38/"><![CDATA[<blockquote>
  <p>Not all those who wander are lost.</p>

  <p>– J.R.R. Tolkien</p>
</blockquote>

<p>Today I’m happy to announce <a href="https://github.com/flycheck/flycheck/releases/tag/v38.0">Flycheck 38</a> - easily the biggest and most
ambitious Flycheck release since I took over the stewardship of the project.
It’s the release where Flycheck grows a proper story for language servers, gets
the kind of inline diagnostics you’d expect from a modern editor, and learns to
apply fixes - all without giving up the checker model that made it popular in the
first place.</p>

<p>The version number, I’ll admit, doesn’t do this one justice - it’s just the next
integer after 37, and nothing about “38” whispers “special”. But that’s how it
goes with version numbers: some releases are more special than others, and you’d
rarely guess which from the number alone.</p>

<!--more-->

<h2 id="there-and-back-again">There and back again</h2>

<p>A little history, because it’s what makes me this excited. Flycheck was born to
give Emacs a genuinely modern linting experience, back when the built-in options
were, let’s charitably say, uninspiring. For years it was <em>the</em> way to get
on-the-fly checking in Emacs. But then development slowed to a crawl, Flymake got
a ground-up rewrite and quietly caught up in a lot of areas - it even <a href="/blog/2026/07/20/flymake-can-now-show-diagnostics-at-the-end-of-the-line/">grew
end-of-line diagnostics</a> recently - and I started seeing people
wonder aloud whether Flycheck still brought anything to the table.</p>

<p>I get the question - a stagnant project invites it. But I never believed Flycheck
was done; it was just resting. This release is my answer: proof that it can still
innovate and still delight. And I’m genuinely grateful for the competition. Flymake
pushing hard is exactly what nudged me to think bigger and bolder than another
round of bugfixes. Competition in this space is a good thing, full stop - it makes
both projects better and Emacs users the winners. If you’re curious how the two
stack up now, the manual keeps an <a href="https://www.flycheck.org/en/latest/user/flycheck-versus-flymake.html">honest side-by-side</a>.</p>

<p>So, in the spirit of boldly going where many editors have gone before, here’s what’s
new.</p>

<h2 id="eglot-support-finally-built-in">Eglot support, finally built in</h2>

<p>For years the story around Flycheck and LSP was awkward. Eglot renders its
diagnostics through Flymake and offers no Flycheck backend of its own, so if you
wanted your LSP errors in Flycheck’s error list you had to reach for the
third-party <code class="language-plaintext highlighter-rouge">flycheck-eglot</code> package. It worked, but “install another package to
bridge two things that ship with Emacs” never sat right with me.</p>

<p>Flycheck now bridges that gap itself. Enable <code class="language-plaintext highlighter-rouge">global-flycheck-eglot-mode</code> and an
Eglot-managed buffer reports the server’s diagnostics through Flycheck - the
error list, the navigation, the fringe, all of it - while Eglot keeps doing the
LSP heavy lifting. This obsoletes the <code class="language-plaintext highlighter-rouge">flycheck-eglot</code> package.<sup id="fnref:collision" role="doc-noteref"><a href="#fn:collision" class="footnote" rel="footnote">1</a></sup></p>

<p>And because Flycheck reads the raw LSP diagnostic rather than the flattened
Flymake one, the bridge surfaces things Flymake-over-Eglot drops on the floor:
an LSP <code class="language-plaintext highlighter-rouge">quickfix</code> code action becomes a Flycheck fix you can apply with <code class="language-plaintext highlighter-rouge">C-c ! f</code>,
and a diagnostic’s related locations become navigable.</p>

<h2 id="beautiful-inline-diagnostics">Beautiful inline diagnostics</h2>

<p>The other thing I really wanted was inline messages - errors shown right next
to the code they refer to, the way VS Code’s Error Lens, Neovim, Helix and Zed
all do it. Flycheck 38 ships this out of the box.</p>

<p><img src="/assets/images/flycheck-annotate-inline.png" alt="Inline diagnostics with flycheck-annotate-mode" /></p>

<p>Turn on <code class="language-plaintext highlighter-rouge">flycheck-annotate-mode</code> and you get it. There are two layouts - a
compact <code class="language-plaintext highlighter-rouge">eol</code> message after the line, and a roomy <code class="language-plaintext highlighter-rouge">below</code> layout that lays the
full messages out on their own lines underneath, with connectors pointing at the
offending column. By default the line at point gets the roomy treatment while
the rest stay compact, so the error you’re working on is spelled out in full
without every other line shouting for attention. There’s also an Error Lens-style
whole-line background tint and a right-aligned <code class="language-plaintext highlighter-rouge">sideline</code> style if that’s your
thing - the <a href="https://www.flycheck.org/en/latest/user/error-reports.html#inline-error-messages">manual</a> has a shot of each.</p>

<p>Turn it on everywhere with the global mode:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nv">global-flycheck-annotate-mode</span> <span class="mi">1</span><span class="p">)</span>
<span class="c1">;; optional: the Error Lens-style whole-line tint</span>
<span class="p">(</span><span class="k">setq</span> <span class="nv">flycheck-annotate-background</span> <span class="no">t</span><span class="p">)</span>
</code></pre></div></div>

<p>A word on the name, since it’s a funny little story. I’d have loved to call this
<code class="language-plaintext highlighter-rouge">flycheck-inline-mode</code>, but that name was taken by the (now deprecated)
<code class="language-plaintext highlighter-rouge">flycheck-inline</code> package. “Diagnostics” was the other obvious choice, except
Flycheck has always called them <em>errors</em>, not diagnostics - <code class="language-plaintext highlighter-rouge">flycheck-error</code>, the
error list, <code class="language-plaintext highlighter-rouge">flycheck-checkers</code> - and I didn’t want to introduce a second
vocabulary for the same thing. So <code class="language-plaintext highlighter-rouge">flycheck-annotate-mode</code> it is. Naming things
is (still) hard.</p>

<h2 id="native-lsp-support-no-client-required">Native LSP support, no client required</h2>

<p>And to top things off: Flycheck can now talk to a language server <strong>directly</strong> -
no Eglot, no <code class="language-plaintext highlighter-rouge">lsp-mode</code>, no full LSP client at all.</p>

<p><img src="/assets/images/flycheck-lsp-native.png" alt="RuboCop's LSP diagnostics through the native lsp checker, with fixes" /></p>

<p>Here’s the itch this scratches. A growing number of linters ship their own LSP
server - RuboCop, Ruff, Biome, Harper and friends - and a traditional command
checker spawns the linter afresh on every check, paying its startup cost over
and over (anyone who’s waited on <code class="language-plaintext highlighter-rouge">rubocop</code> loading a big project knows the
feeling). The linter’s own LSP server stays resident and lints incrementally
instead, so checks are much snappier - and you get that without running a full
language server and client just to see some diagnostics.</p>

<p>Enable <code class="language-plaintext highlighter-rouge">global-flycheck-lsp-mode</code> and it works out of the box for RuboCop (Ruby),
Ruff (Python), Biome (JavaScript, TypeScript, JSON, CSS) and Harper (Markdown
prose). Each server is only started if its program is installed, so turning the
mode on globally is safe. Want a different one? It’s a one-liner:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">;; Standard instead of RuboCop for Ruby</span>
<span class="p">(</span><span class="nb">setf</span> <span class="p">(</span><span class="nv">alist-get</span> <span class="ss">'ruby-mode</span> <span class="nv">flycheck-lsp-servers</span><span class="p">)</span> <span class="o">'</span><span class="p">(</span><span class="s">"standardrb"</span> <span class="s">"--lsp"</span><span class="p">))</span>
</code></pre></div></div>

<p>The whole thing is built on Emacs’ own <code class="language-plaintext highlighter-rouge">jsonrpc</code> library, so there’s no new
dependency. And where the server offers them - RuboCop’s autocorrects, Ruff’s and
Biome’s quickfixes - those show up as Flycheck fixes too. It’s meant for the
diagnostics-only case; when you want a full language server with completion and
hover, run it through Eglot and use <code class="language-plaintext highlighter-rouge">flycheck-eglot-mode</code>. The manual has a
<a href="https://www.flycheck.org/en/latest/user/syntax-checks.html#which-lsp-integration-should-i-use">table</a> to help you pick.</p>

<h2 id="project-wide-diagnostics">Project-wide diagnostics</h2>

<p>Flycheck has always been a resolutely buffer-local affair: it checks the file
you’re looking at and shows you those errors. That’s great right up until you want
the bigger picture - every problem across the files you have open, plus the
cross-file errors that checkers like <code class="language-plaintext highlighter-rouge">tsc</code>, <code class="language-plaintext highlighter-rouge">cargo check</code> and <code class="language-plaintext highlighter-rouge">mypy</code> genuinely
know about but the per-buffer view quietly throws away.</p>

<p>Press <code class="language-plaintext highlighter-rouge">P</code> in the error list and it flips to a project-wide scope: errors
aggregated across every open Flycheck buffer, with those cross-file diagnostics
finally given somewhere to live. It’s the closest Flycheck has come to a “problems”
panel, and it’s quickly become one of my favourite things to actually use day to
day.</p>

<p><img src="/assets/images/flycheck-error-list-project.png" alt="The error list in project-wide scope" /></p>

<p>Notice the <code class="language-plaintext highlighter-rouge">models.py</code> type error in there: it was reported while checking
<code class="language-plaintext highlighter-rouge">api.py</code>, and the old per-buffer view would have dropped it on the floor. The
<code class="language-plaintext highlighter-rouge">[project]</code> tag in the mode line tells you you’re looking at the whole project
rather than a single file.</p>

<h2 id="checking-remote-files-over-tramp">Checking remote files over TRAMP</h2>

<p>This one is simple to describe and was honestly overdue: Flycheck now runs
checkers over TRAMP. Open a file on a remote host and the checker runs <em>there</em>, on
the remote machine, against the real environment - where before it simply refused
to run at all. If you edit code on servers or inside containers over TRAMP, this
alone might be worth the upgrade.</p>

<h2 id="and-plenty-more">And plenty more</h2>

<p>The three headliners above lean on a lot of supporting work that landed in the
same release. The highlights:</p>

<ul>
  <li>Flycheck can <strong>apply fixes</strong> now. <code class="language-plaintext highlighter-rouge">C-c ! f</code> (<code class="language-plaintext highlighter-rouge">flycheck-fix-error-at-point</code>)
applies the machine-applicable fix a checker suggested, <code class="language-plaintext highlighter-rouge">C-c ! F</code> applies every
fix in the buffer at once as a single undoable change, and fixable errors get a
distinct fringe indicator - a little “fix available” lightbulb. <code class="language-plaintext highlighter-rouge">eslint --fix</code>,
<code class="language-plaintext highlighter-rouge">cargo clippy</code>’s suggestions, <code class="language-plaintext highlighter-rouge">ruff</code>, <code class="language-plaintext highlighter-rouge">shellcheck</code> and any SARIF-based checker
carry these fixes, which Flycheck used to parse and throw away.</li>
  <li>The <strong>error list</strong> got a serious overhaul: group errors by file, checker or
level (and combine those dimensions), collapse the groups, and drive it all
with the mouse via a strip at the top.</li>
  <li>Errors can carry <strong>secondary locations</strong> - the earlier definition behind a
redefinition, the borrow behind a Rust lifetime error. Jump to them with
<code class="language-plaintext highlighter-rouge">C-c ! j</code>, and they show up after the message inline and in the error list.</li>
  <li>A running check is <strong>interrupted</strong> when a newer one starts (unless it’s already
made real progress), so a slow checker no longer makes Flycheck feel sluggish,
and the error list no longer rescans all its rows on every cursor move.</li>
</ul>

<p><img src="/assets/images/flycheck-error-list-grouped.png" alt="The error list grouped by file and level" /></p>

<p>There’s more in the <a href="https://github.com/flycheck/flycheck/blob/master/CHANGELOG.md">changelog</a>, but that’s the shape of it.</p>

<h2 id="putting-it-all-together">Putting it all together</h2>

<p>If you want the full modern setup - on-the-fly checking everywhere, inline
diagnostics, and your LSP server’s diagnostics flowing through Flycheck - here’s
a <code class="language-plaintext highlighter-rouge">use-package</code> block that turns it all on:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nb">use-package</span> <span class="nv">flycheck</span>
  <span class="ss">:ensure</span> <span class="no">t</span>
  <span class="ss">:hook</span> <span class="p">((</span><span class="nv">after-init</span> <span class="o">.</span> <span class="nv">global-flycheck-mode</span><span class="p">)</span>
         <span class="c1">;; Show diagnostics inline, next to the code (Error Lens style)</span>
         <span class="p">(</span><span class="nv">after-init</span> <span class="o">.</span> <span class="nv">global-flycheck-annotate-mode</span><span class="p">))</span>
  <span class="ss">:config</span>
  <span class="c1">;; Report Eglot's LSP diagnostics through Flycheck</span>
  <span class="p">(</span><span class="nv">global-flycheck-eglot-mode</span> <span class="mi">1</span><span class="p">))</span>
</code></pre></div></div>

<p>Prefer to skip Eglot and read diagnostics straight from a linter’s own LSP
server (RuboCop, Ruff, Biome, Harper)? Swap that last line for
<code class="language-plaintext highlighter-rouge">(global-flycheck-lsp-mode 1)</code> instead. Reach for the native checker when all
you want is diagnostics, and the Eglot bridge when you also want a full language
server’s completion and hover.</p>

<h2 id="upgrading">Upgrading</h2>

<p>Most setups will just keep working. The one thing to watch: the built-in
<code class="language-plaintext highlighter-rouge">flycheck-eglot-mode</code> reuses the names of the old third-party <code class="language-plaintext highlighter-rouge">flycheck-eglot</code>
package, so if you have that installed, uninstall it before relying on the
built-in mode - otherwise the two define the same commands and clash.</p>

<h2 id="a-word-on-funding">A word on funding</h2>

<p>Let me get a little uncomfortably candid here. In the couple of years I’ve been
maintaining Flycheck, its <a href="https://opencollective.com/flycheck">OpenCollective</a> has taken in less than
$300 - total. Individual donations haven’t exactly moved the needle either. I’m
not saying this to guilt anyone; it’s just the everyday reality of open source.
Popular projects are a lot of work, and the usual reward is the quiet satisfaction
of using something you helped make a bit better.</p>

<p>Still, if Flycheck saves you time - especially if it does so at work - please
consider chipping in through <a href="https://opencollective.com/flycheck">OpenCollective</a>, <a href="https://github.com/sponsors/bbatsov">GitHub
Sponsors</a>, or any of the <a href="https://github.com/flycheck/flycheck#sponsoring">other options</a> linked from the
README. Even a small recurring amount, multiplied across the people who lean on
this thing every day, would make a real difference to how much time I can put into
it.</p>

<h2 id="closing-thoughts">Closing thoughts</h2>

<blockquote>
  <p>Even the smallest person can change the course of the future.</p>

  <p>– Galadriel</p>
</blockquote>

<p>When I took over Flycheck, my motivation was simple: keep the project alive, and
keep the competition in this corner of Emacs going. For a long stretch that meant
little more than keeping the lights on. This release is the first time in a while
it’s genuinely moved forward in a big way, and I’m proud of where it landed -
modern diagnostics UX, first-class LSP support in two flavours, project-wide
diagnostics, and fixes, all while staying true to the checker model people love it
for. Call it the return of the Jedi. I hope you’ll agree I’ve been at least
modestly successful at what I set out to do.</p>

<p>Huge thanks to everyone who tested, reported and nudged this along. Give
<code class="language-plaintext highlighter-rouge">flycheck-annotate-mode</code> and <code class="language-plaintext highlighter-rouge">flycheck-lsp-mode</code> a spin and let me know what you
think.</p>

<p>Keep hacking!</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:collision" role="doc-endnote">
      <p>The built-in mode even reuses the same mode names, so having both
installed is a genuine clash - one more reason to drop the old package. <a href="#fnref:collision" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Bozhidar Batsov</name></author><category term="Flycheck" /><category term="LSP" /><category term="Eglot" /><summary type="html"><![CDATA[Not all those who wander are lost. – J.R.R. Tolkien Today I’m happy to announce Flycheck 38 - easily the biggest and most ambitious Flycheck release since I took over the stewardship of the project. It’s the release where Flycheck grows a proper story for language servers, gets the kind of inline diagnostics you’d expect from a modern editor, and learns to apply fixes - all without giving up the checker model that made it popular in the first place. The version number, I’ll admit, doesn’t do this one justice - it’s just the next integer after 37, and nothing about “38” whispers “special”. But that’s how it goes with version numbers: some releases are more special than others, and you’d rarely guess which from the number alone.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://emacsredux.com/assets/og-image.png" /><media:content medium="image" url="https://emacsredux.com/assets/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">CIDER and Projectile Meet Embark</title><link href="https://emacsredux.com/blog/2026/07/25/cider-and-projectile-meet-embark/" rel="alternate" type="text/html" title="CIDER and Projectile Meet Embark" /><published>2026-07-25T06:00:00+00:00</published><updated>2026-07-25T06:00:00+00:00</updated><id>https://emacsredux.com/blog/2026/07/25/cider-and-projectile-meet-embark</id><content type="html" xml:base="https://emacsredux.com/blog/2026/07/25/cider-and-projectile-meet-embark/"><![CDATA[<p><a href="https://github.com/oantolin/embark">Embark</a> is one of those packages that
quietly rewires how you use Emacs. Think of it as a context-aware right-click:
you invoke <code class="language-plaintext highlighter-rouge">embark-act</code> (I keep it on <code class="language-plaintext highlighter-rouge">C-.</code>) on whatever’s at point - a file
name, a symbol, a URL - and Embark offers a menu of things you can do with it.
The neat part is that it’s completely extensible, so you can teach it about new
kinds of targets. Lately two of my projects, CIDER and Projectile, have grown
Embark integrations, in slightly different ways, and both are worth a look.</p>

<p>Let’s start with CIDER, and teach Embark about Clojure symbols, so <code class="language-plaintext highlighter-rouge">embark-act</code>
on one offers a bunch
of CIDER commands:</p>

<p><img src="/assets/images/cider-embark.png" alt="CIDER actions in Embark" /></p>

<p>So <code class="language-plaintext highlighter-rouge">d</code> shows the documentation, <code class="language-plaintext highlighter-rouge">.</code> jumps to the definition, <code class="language-plaintext highlighter-rouge">r</code> finds
references, <code class="language-plaintext highlighter-rouge">i</code> inspects the value, <code class="language-plaintext highlighter-rouge">c</code> opens ClojureDocs and <code class="language-plaintext highlighter-rouge">a</code> runs apropos -
the usual CIDER commands, a keystroke away from wherever your cursor happens to
be.</p>

<p>Here’s the setup. It’s a handful of little wrappers around the CIDER commands, a
keymap that binds them, a target finder that spots a Clojure symbol at point,
and the bit of wiring that ties it all together:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nb">defun</span> <span class="nv">my-cider-embark-doc</span> <span class="p">(</span><span class="nv">sym</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">interactive</span> <span class="s">"sClojure symbol: "</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">cider-doc-lookup</span> <span class="nv">sym</span><span class="p">))</span>

<span class="p">(</span><span class="nb">defun</span> <span class="nv">my-cider-embark-find-def</span> <span class="p">(</span><span class="nv">sym</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">interactive</span> <span class="s">"sClojure symbol: "</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">cider-find-var</span> <span class="no">nil</span> <span class="nv">sym</span><span class="p">))</span>

<span class="p">(</span><span class="nb">defun</span> <span class="nv">my-cider-embark-fn-refs</span> <span class="p">(</span><span class="nv">sym</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">interactive</span> <span class="s">"sClojure symbol: "</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">cider-xref-fn-refs</span> <span class="no">nil</span> <span class="nv">sym</span><span class="p">))</span>

<span class="p">(</span><span class="nb">defun</span> <span class="nv">my-cider-embark-inspect</span> <span class="p">(</span><span class="nv">sym</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">interactive</span> <span class="s">"sClojure symbol: "</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">cider-inspect-expr</span> <span class="nv">sym</span> <span class="p">(</span><span class="nv">cider-current-ns</span><span class="p">)))</span>

<span class="p">(</span><span class="nb">defun</span> <span class="nv">my-cider-embark-clojuredocs</span> <span class="p">(</span><span class="nv">sym</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">interactive</span> <span class="s">"sClojure symbol: "</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">cider-clojuredocs-lookup</span> <span class="nv">sym</span><span class="p">))</span>

<span class="p">(</span><span class="nb">defun</span> <span class="nv">my-cider-embark-apropos</span> <span class="p">(</span><span class="nv">sym</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">interactive</span> <span class="s">"sClojure symbol: "</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">cider-apropos</span> <span class="nv">sym</span><span class="p">))</span>

<span class="p">(</span><span class="nb">defvar</span> <span class="nv">my-cider-embark-symbol-map</span>
  <span class="p">(</span><span class="k">let</span> <span class="p">((</span><span class="nb">map</span> <span class="p">(</span><span class="nv">make-sparse-keymap</span><span class="p">)))</span>
    <span class="p">(</span><span class="nv">define-key</span> <span class="nb">map</span> <span class="s">"d"</span> <span class="nf">#'</span><span class="nv">my-cider-embark-doc</span><span class="p">)</span>
    <span class="p">(</span><span class="nv">define-key</span> <span class="nb">map</span> <span class="s">"."</span> <span class="nf">#'</span><span class="nv">my-cider-embark-find-def</span><span class="p">)</span>
    <span class="p">(</span><span class="nv">define-key</span> <span class="nb">map</span> <span class="s">"r"</span> <span class="nf">#'</span><span class="nv">my-cider-embark-fn-refs</span><span class="p">)</span>
    <span class="p">(</span><span class="nv">define-key</span> <span class="nb">map</span> <span class="s">"i"</span> <span class="nf">#'</span><span class="nv">my-cider-embark-inspect</span><span class="p">)</span>
    <span class="p">(</span><span class="nv">define-key</span> <span class="nb">map</span> <span class="s">"c"</span> <span class="nf">#'</span><span class="nv">my-cider-embark-clojuredocs</span><span class="p">)</span>
    <span class="p">(</span><span class="nv">define-key</span> <span class="nb">map</span> <span class="s">"a"</span> <span class="nf">#'</span><span class="nv">my-cider-embark-apropos</span><span class="p">)</span>
    <span class="nb">map</span><span class="p">))</span>

<span class="p">(</span><span class="nb">defun</span> <span class="nv">my-cider-embark-target</span> <span class="p">()</span>
  <span class="p">(</span><span class="nb">when</span> <span class="p">(</span><span class="nv">derived-mode-p</span> <span class="ss">'clojure-mode</span> <span class="ss">'clojurescript-mode</span> <span class="ss">'clojurec-mode</span>
                        <span class="ss">'clojure-ts-mode</span> <span class="ss">'cider-repl-mode</span><span class="p">)</span>
    <span class="p">(</span><span class="nv">when-let*</span> <span class="p">((</span><span class="nv">bounds</span> <span class="p">(</span><span class="nv">bounds-of-thing-at-point</span> <span class="ss">'symbol</span><span class="p">))</span>
                <span class="p">(</span><span class="nv">sym</span> <span class="p">(</span><span class="nv">cider-symbol-at-point</span><span class="p">)))</span>
      <span class="p">(</span><span class="nb">unless</span> <span class="p">(</span><span class="nv">string-empty-p</span> <span class="nv">sym</span><span class="p">)</span>
        <span class="o">`</span><span class="p">(</span><span class="nv">cider-clojure-symbol</span> <span class="o">,</span><span class="nv">sym</span> <span class="o">.</span> <span class="o">,</span><span class="nv">bounds</span><span class="p">)))))</span>

<span class="p">(</span><span class="nv">with-eval-after-load</span> <span class="ss">'embark</span>
  <span class="p">(</span><span class="nv">add-to-list</span> <span class="ss">'embark-target-finders</span> <span class="nf">#'</span><span class="nv">my-cider-embark-target</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">add-to-list</span> <span class="ss">'embark-keymap-alist</span> <span class="o">'</span><span class="p">(</span><span class="nv">cider-clojure-symbol</span> <span class="nv">my-cider-embark-symbol-map</span><span class="p">))</span>
  <span class="p">(</span><span class="nv">add-to-list</span> <span class="ss">'embark-keymap-alist</span> <span class="o">'</span><span class="p">(</span><span class="nv">cider</span> <span class="nv">my-cider-embark-symbol-map</span><span class="p">)))</span>
</code></pre></div></div>

<p>That last <code class="language-plaintext highlighter-rouge">cider</code> line is my favorite bit. CIDER’s symbol prompts (things like
<code class="language-plaintext highlighter-rouge">cider-doc</code> and <code class="language-plaintext highlighter-rouge">cider-find-var</code>) can read through <code class="language-plaintext highlighter-rouge">completing-read</code> and tag
their candidates with the <code class="language-plaintext highlighter-rouge">cider</code> completion category, so pointing that category
at the same keymap means <code class="language-plaintext highlighter-rouge">embark-act</code> works on the <em>candidates</em> too. You start
typing a symbol to read its docs, spot it in the candidate list, decide you’d
rather jump to its definition - <code class="language-plaintext highlighter-rouge">C-. .</code> and you’re there, no retyping. Symbols
in your code and candidates in the minibuffer end up sharing one set of actions.</p>

<p>Projectile took the opposite tack and ships its Embark integration out of the
box - there’s nothing to configure, it wires itself up as soon as Embark is
loaded. Two things happen. Acting on a project candidate (say, in
<code class="language-plaintext highlighter-rouge">projectile-switch-project</code>) gives you project-specific actions - switch to it,
open its VC interface, drop into <code class="language-plaintext highlighter-rouge">dired</code>, or remove it from the known-projects
list - instead of the generic file actions you’d otherwise get:</p>

<p><img src="/assets/images/projectile-embark.png" alt="Embark actions on a Projectile project" /></p>

<p>And when you act on a project <em>file</em> candidate, Projectile makes sure the path
resolves against the project root, so Embark’s file actions land on the right
file no matter what your <code class="language-plaintext highlighter-rouge">default-directory</code> happens to be.</p>

<p>You might wonder why Projectile ships this while CIDER leaves it to you. It comes
down to what each integration is. Projectile’s is mostly about making the
completion categories it already exposes behave correctly under Embark, plus a
small and fairly obvious set of project actions - there isn’t much to bikeshed
there. CIDER’s symbol actions are a bigger, more personal grab-bag: which
commands you want on that menu, and which keys you put them on, is very much a
matter of taste. A recipe you copy and tailor felt like the better fit. Same
idea, two problems that wanted different answers.</p>

<p>That’s all I have for you today. Keep hacking!</p>

<p><strong>P.S.</strong> If you’re not using Embark yet, the actions above are just the start -
once you start thinking of <code class="language-plaintext highlighter-rouge">embark-act</code> as “do something with the thing at
point”, it’s hard to stop.</p>]]></content><author><name>Bozhidar Batsov</name></author><category term="CIDER" /><category term="Projectile" /><category term="Embark" /><category term="Clojure" /><summary type="html"><![CDATA[Embark is one of those packages that quietly rewires how you use Emacs. Think of it as a context-aware right-click: you invoke embark-act (I keep it on C-.) on whatever’s at point - a file name, a symbol, a URL - and Embark offers a menu of things you can do with it. The neat part is that it’s completely extensible, so you can teach it about new kinds of targets. Lately two of my projects, CIDER and Projectile, have grown Embark integrations, in slightly different ways, and both are worth a look. Let’s start with CIDER, and teach Embark about Clojure symbols, so embark-act on one offers a bunch of CIDER commands: So d shows the documentation, . jumps to the definition, r finds references, i inspects the value, c opens ClojureDocs and a runs apropos - the usual CIDER commands, a keystroke away from wherever your cursor happens to be. Here’s the setup. It’s a handful of little wrappers around the CIDER commands, a keymap that binds them, a target finder that spots a Clojure symbol at point, and the bit of wiring that ties it all together: (defun my-cider-embark-doc (sym) (interactive "sClojure symbol: ") (cider-doc-lookup sym)) (defun my-cider-embark-find-def (sym) (interactive "sClojure symbol: ") (cider-find-var nil sym)) (defun my-cider-embark-fn-refs (sym) (interactive "sClojure symbol: ") (cider-xref-fn-refs nil sym)) (defun my-cider-embark-inspect (sym) (interactive "sClojure symbol: ") (cider-inspect-expr sym (cider-current-ns))) (defun my-cider-embark-clojuredocs (sym) (interactive "sClojure symbol: ") (cider-clojuredocs-lookup sym)) (defun my-cider-embark-apropos (sym) (interactive "sClojure symbol: ") (cider-apropos sym)) (defvar my-cider-embark-symbol-map (let ((map (make-sparse-keymap))) (define-key map "d" #'my-cider-embark-doc) (define-key map "." #'my-cider-embark-find-def) (define-key map "r" #'my-cider-embark-fn-refs) (define-key map "i" #'my-cider-embark-inspect) (define-key map "c" #'my-cider-embark-clojuredocs) (define-key map "a" #'my-cider-embark-apropos) map)) (defun my-cider-embark-target () (when (derived-mode-p 'clojure-mode 'clojurescript-mode 'clojurec-mode 'clojure-ts-mode 'cider-repl-mode) (when-let* ((bounds (bounds-of-thing-at-point 'symbol)) (sym (cider-symbol-at-point))) (unless (string-empty-p sym) `(cider-clojure-symbol ,sym . ,bounds))))) (with-eval-after-load 'embark (add-to-list 'embark-target-finders #'my-cider-embark-target) (add-to-list 'embark-keymap-alist '(cider-clojure-symbol my-cider-embark-symbol-map)) (add-to-list 'embark-keymap-alist '(cider my-cider-embark-symbol-map))) That last cider line is my favorite bit. CIDER’s symbol prompts (things like cider-doc and cider-find-var) can read through completing-read and tag their candidates with the cider completion category, so pointing that category at the same keymap means embark-act works on the candidates too. You start typing a symbol to read its docs, spot it in the candidate list, decide you’d rather jump to its definition - C-. . and you’re there, no retyping. Symbols in your code and candidates in the minibuffer end up sharing one set of actions. Projectile took the opposite tack and ships its Embark integration out of the box - there’s nothing to configure, it wires itself up as soon as Embark is loaded. Two things happen. Acting on a project candidate (say, in projectile-switch-project) gives you project-specific actions - switch to it, open its VC interface, drop into dired, or remove it from the known-projects list - instead of the generic file actions you’d otherwise get: And when you act on a project file candidate, Projectile makes sure the path resolves against the project root, so Embark’s file actions land on the right file no matter what your default-directory happens to be. You might wonder why Projectile ships this while CIDER leaves it to you. It comes down to what each integration is. Projectile’s is mostly about making the completion categories it already exposes behave correctly under Embark, plus a small and fairly obvious set of project actions - there isn’t much to bikeshed there. CIDER’s symbol actions are a bigger, more personal grab-bag: which commands you want on that menu, and which keys you put them on, is very much a matter of taste. A recipe you copy and tailor felt like the better fit. Same idea, two problems that wanted different answers. That’s all I have for you today. Keep hacking! P.S. If you’re not using Embark yet, the actions above are just the start - once you start thinking of embark-act as “do something with the thing at point”, it’s hard to stop.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://emacsredux.com/assets/og-image.png" /><media:content medium="image" url="https://emacsredux.com/assets/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Dedicate Windows with toggle-window-dedicated</title><link href="https://emacsredux.com/blog/2026/07/22/dedicate-windows-with-toggle-window-dedicated/" rel="alternate" type="text/html" title="Dedicate Windows with toggle-window-dedicated" /><published>2026-07-22T06:30:00+00:00</published><updated>2026-07-22T06:30:00+00:00</updated><id>https://emacsredux.com/blog/2026/07/22/dedicate-windows-with-toggle-window-dedicated</id><content type="html" xml:base="https://emacsredux.com/blog/2026/07/22/dedicate-windows-with-toggle-window-dedicated/"><![CDATA[<p>You’ve carefully arranged your windows just the way you want them - source code
on the left, tests on the right, maybe a shell at the bottom. Then you run some
command that calls <code class="language-plaintext highlighter-rouge">display-buffer</code>, and suddenly one of your carefully placed
windows gets hijacked to show a <code class="language-plaintext highlighter-rouge">*Help*</code> buffer or a compilation log. We’ve all
been there.</p>

<p>The <code class="language-plaintext highlighter-rouge">display-buffer</code> machinery is one of Emacs’s most powerful features, but also
one of its most frustrating. Emacs 30 adds a simple, practical tool to help tame
it: <code class="language-plaintext highlighter-rouge">toggle-window-dedicated</code>.</p>

<!--more-->

<h2 id="how-it-works">How it works</h2>

<p>The concept of “dedicated” windows has existed in Emacs for a long time - a
dedicated window tells <code class="language-plaintext highlighter-rouge">display-buffer</code> “don’t touch me, display your buffer
somewhere else.” But setting this up required Elisp:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nv">set-window-dedicated-p</span> <span class="p">(</span><span class="nv">selected-window</span><span class="p">)</span> <span class="no">t</span><span class="p">)</span>
</code></pre></div></div>

<p>Not exactly something you’d do interactively in the middle of a coding session.
Emacs 30 changes this with a simple keybinding - <code class="language-plaintext highlighter-rouge">C-x w d</code> toggles the current
window’s dedicated status.</p>

<p>That’s it. Press it once, and the window is dedicated. Press it again, and it’s
back to normal.</p>

<p>Here’s the whole thing in action. I dedicate the code window on the left (watch
the <code class="language-plaintext highlighter-rouge">d</code> appear in its mode line), then ask for help with <code class="language-plaintext highlighter-rouge">C-h f</code> - and instead of
hijacking my code window, the <code class="language-plaintext highlighter-rouge">*Help*</code> buffer politely opens on the right:</p>

<p><img src="/assets/images/dedicate-windows-demo.gif" alt="Dedicating a window so C-h f opens the Help buffer elsewhere instead of taking over" /></p>

<h2 id="mode-line-indicator">Mode line indicator</h2>

<p>When a window is dedicated, you’ll see a small indicator in the mode line:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">d</code> - the window is dedicated (soft dedication)</li>
  <li><code class="language-plaintext highlighter-rouge">D</code> - the window is strongly dedicated</li>
</ul>

<p>The indicator appears before the buffer name, right after the modification
indicators (the usual <code class="language-plaintext highlighter-rouge">---</code> area).</p>

<h2 id="practical-uses">Practical uses</h2>

<ul>
  <li>Lock your source code windows so that help buffers, grep results, or
compilation output land in other windows instead.</li>
  <li>Protect your shell or REPL window from being taken over.</li>
  <li>Stabilize complex window layouts when running commands that spawn new
buffers.</li>
</ul>

<h2 id="a-workflow-tip">A workflow tip</h2>

<p>A nice pattern is to set up your window layout, then quickly dedicate the windows
you want to protect:</p>

<ol>
  <li>Arrange your windows</li>
  <li>In each window you want to lock, press <code class="language-plaintext highlighter-rouge">C-x w d</code></li>
  <li>Go about your work - <code class="language-plaintext highlighter-rouge">display-buffer</code> will respect your dedicated windows</li>
</ol>

<p>When you’re done and want to return to a more flexible layout, just toggle them
off again.</p>

<p>I put off learning the <code class="language-plaintext highlighter-rouge">display-buffer</code> machinery for years - it’s famously
fiddly - so having a one-keystroke escape hatch for the most common annoyance is
a real relief. It won’t replace a properly tuned <code class="language-plaintext highlighter-rouge">display-buffer-alist</code>, but for
quickly protecting a window in the middle of a session it’s hard to beat.</p>

<p>How do you keep <code class="language-plaintext highlighter-rouge">display-buffer</code> from scribbling over your carefully arranged
layout - dedicated windows, a hand-tuned <code class="language-plaintext highlighter-rouge">display-buffer-alist</code>, or something
else entirely? I’d love to hear about it in the comments!</p>

<p>That’s all I have for you today. Keep your windows in their place!</p>]]></content><author><name>Bozhidar Batsov</name></author><category term="Emacs 30" /><summary type="html"><![CDATA[You’ve carefully arranged your windows just the way you want them - source code on the left, tests on the right, maybe a shell at the bottom. Then you run some command that calls display-buffer, and suddenly one of your carefully placed windows gets hijacked to show a *Help* buffer or a compilation log. We’ve all been there. The display-buffer machinery is one of Emacs’s most powerful features, but also one of its most frustrating. Emacs 30 adds a simple, practical tool to help tame it: toggle-window-dedicated.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://emacsredux.com/assets/og-image.png" /><media:content medium="image" url="https://emacsredux.com/assets/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Right-aligned Mode Line Elements</title><link href="https://emacsredux.com/blog/2026/07/21/right-aligned-mode-line-elements/" rel="alternate" type="text/html" title="Right-aligned Mode Line Elements" /><published>2026-07-21T05:00:00+00:00</published><updated>2026-07-21T05:00:00+00:00</updated><id>https://emacsredux.com/blog/2026/07/21/right-aligned-mode-line-elements</id><content type="html" xml:base="https://emacsredux.com/blog/2026/07/21/right-aligned-mode-line-elements/"><![CDATA[<p>Emacs users have long wanted the ability to push certain mode line elements to
the right edge of the window. Think of it like having a left-aligned and
right-aligned section in your mode line - buffer name on the left, maybe the time
or some status info on the right.</p>

<p>Before Emacs 30, achieving this required various hacks involving padding
calculations and propertized strings. It was doable, but fragile and ugly.</p>

<p>Emacs 30 makes it trivial with <code class="language-plaintext highlighter-rouge">mode-line-format-right-align</code>.</p>

<!--more-->

<h2 id="how-it-works">How it works</h2>

<p>Just insert the symbol <code class="language-plaintext highlighter-rouge">mode-line-format-right-align</code> into your
<code class="language-plaintext highlighter-rouge">mode-line-format</code>. Everything before it is left-aligned (as usual), and
everything after it gets pushed to the right edge.</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nv">setq-default</span> <span class="nv">mode-line-format</span>
              <span class="o">'</span><span class="p">(</span><span class="s">"%e"</span> <span class="nv">mode-line-front-space</span>
                <span class="nv">mode-line-mule-info</span>
                <span class="nv">mode-line-modified</span>
                <span class="s">" "</span>
                <span class="nv">mode-line-buffer-identification</span>
                <span class="nv">mode-line-format-right-align</span>
                <span class="nv">mode-line-modes</span>
                <span class="nv">mode-line-misc-info</span>
                <span class="nv">mode-line-end-spaces</span><span class="p">))</span>
</code></pre></div></div>

<p>In this example, the buffer identification stays on the left, while modes and
miscellaneous info are pushed to the right.</p>

<h2 id="controlling-the-alignment-edge">Controlling the alignment edge</h2>

<p>By default, right-aligned elements are pushed to the extreme right of the
window. You can control this with <code class="language-plaintext highlighter-rouge">mode-line-right-align-edge</code>:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">;; Align to the left edge of the right fringe (default is 'window)</span>
<span class="p">(</span><span class="k">setq</span> <span class="nv">mode-line-right-align-edge</span> <span class="ss">'right-fringe</span><span class="p">)</span>
</code></pre></div></div>

<p>The available values are:</p>

<table>
  <thead>
    <tr>
      <th>Value</th>
      <th>Alignment point</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">window</code></td>
      <td>Extreme right edge of the window (default)</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">right-fringe</code></td>
      <td>Left edge of the right fringe</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">right-margin</code></td>
      <td>Left edge of the right margin</td>
    </tr>
  </tbody>
</table>

<h2 id="a-practical-example">A practical example</h2>

<p>Here’s a minimal setup that puts the buffer name and modification status on the
left, and the current line/column and major mode on the right:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nv">setq-default</span> <span class="nv">mode-line-format</span>
              <span class="o">'</span><span class="p">(</span><span class="s">" %+ "</span>
                <span class="nv">mode-line-buffer-identification</span>
                <span class="nv">mode-line-format-right-align</span>
                <span class="nv">mode-line-position</span>
                <span class="s">" "</span>
                <span class="nv">mode-line-modes</span><span class="p">))</span>
</code></pre></div></div>

<p>And here’s the result - the buffer name sits on the left while the position
and major mode are pushed all the way to the right:</p>

<p><img src="/assets/images/mode-line-right-align.png" alt="A mode line with the buffer name on the left and the position and modes right-aligned" /></p>

<p>Clean, readable, and no hacks required.</p>

<p>For years I put up with a mode line that was either cluttered on the left or
propped up with fragile padding hacks that broke the moment I resized a window.
Having a proper right-aligned section built into Emacs feels almost too easy -
the kind of small quality-of-life fix that makes you wonder what took so long.</p>

<p>What do you like to keep on the right side of your mode line - the time, the
battery level, some VC info? I’d love to hear how you’ve arranged yours in the
comments!</p>

<p>That’s all I have for you today. Keep your mode line in line!</p>]]></content><author><name>Bozhidar Batsov</name></author><category term="Emacs 30" /><summary type="html"><![CDATA[Emacs users have long wanted the ability to push certain mode line elements to the right edge of the window. Think of it like having a left-aligned and right-aligned section in your mode line - buffer name on the left, maybe the time or some status info on the right. Before Emacs 30, achieving this required various hacks involving padding calculations and propertized strings. It was doable, but fragile and ugly. Emacs 30 makes it trivial with mode-line-format-right-align.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://emacsredux.com/assets/og-image.png" /><media:content medium="image" url="https://emacsredux.com/assets/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Flymake Can Now Show Diagnostics at the End of the Line</title><link href="https://emacsredux.com/blog/2026/07/20/flymake-can-now-show-diagnostics-at-the-end-of-the-line/" rel="alternate" type="text/html" title="Flymake Can Now Show Diagnostics at the End of the Line" /><published>2026-07-20T06:30:00+00:00</published><updated>2026-07-20T06:30:00+00:00</updated><id>https://emacsredux.com/blog/2026/07/20/flymake-can-now-show-diagnostics-at-the-end-of-the-line</id><content type="html" xml:base="https://emacsredux.com/blog/2026/07/20/flymake-can-now-show-diagnostics-at-the-end-of-the-line/"><![CDATA[<p>If you’ve used modern editors like VS Code, you’ve probably noticed how they
display error and warning messages inline, right at the end of the offending
line. It’s a nice touch - you don’t have to hover over a squiggly underline or
check a separate diagnostics buffer to see what’s wrong.</p>

<p>Emacs 30 brings this capability to Flymake with the new
<code class="language-plaintext highlighter-rouge">flymake-show-diagnostics-at-end-of-line</code> option.</p>

<!--more-->

<h2 id="enabling-it">Enabling it</h2>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="k">setq</span> <span class="nv">flymake-show-diagnostics-at-end-of-line</span> <span class="no">t</span><span class="p">)</span>
</code></pre></div></div>

<p>With this set, Flymake will display diagnostic summaries right at the end of
each affected line, in addition to the usual fringe indicators and
underlines. Here’s what it looks like in an Emacs Lisp buffer with a few
issues (an error, a warning, and a checkdoc note):</p>

<p><img src="/assets/images/flymake-end-of-line-diagnostics.png" alt="Flymake showing an error, a warning and a note at the end of the offending lines" /></p>

<h2 id="display-options">Display options</h2>

<p>The option accepts three values:</p>

<table>
  <thead>
    <tr>
      <th>Value</th>
      <th>Behavior</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">nil</code></td>
      <td>Don’t show inline diagnostics (default)</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">short</code></td>
      <td>Show only the most severe diagnostic per line</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">t</code></td>
      <td>Show all diagnostics for the line</td>
    </tr>
  </tbody>
</table>

<p>If a line has both a warning and an error, the <code class="language-plaintext highlighter-rouge">short</code> setting will only show the
error. Using <code class="language-plaintext highlighter-rouge">t</code> shows everything - which can get a bit noisy on lines with
multiple issues, but gives you the complete picture at a glance.</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">;; Only show the most important diagnostic per line</span>
<span class="p">(</span><span class="k">setq</span> <span class="nv">flymake-show-diagnostics-at-end-of-line</span> <span class="ss">'short</span><span class="p">)</span>
</code></pre></div></div>

<h2 id="is-this-distracting">Is this distracting?</h2>

<p>Honestly, it depends on your taste. The Emacs documentation itself acknowledges
the trade-off:</p>

<blockquote>
  <p>Depending on your preference, this can either be distracting and easily
confused with actual code, or a significant early aid that relieves you from
moving the buffer or reaching for the mouse to consult an error message.</p>
</blockquote>

<p>I’d suggest trying it for a few days. If you find it too noisy, the <code class="language-plaintext highlighter-rouge">short</code>
setting is a good middle ground - you still get inline feedback, but limited to
the most severe issue on each line.</p>

<p>I was sure I’d hate this - text floating around in my buffer sounded like pure
clutter - but the <code class="language-plaintext highlighter-rouge">short</code> variant won me over surprisingly fast. Having the
message right there, without reaching for the mouse or popping open the
diagnostics buffer, is one of those small conveniences you stop noticing
precisely because it’s always quietly helping.</p>

<p>How do you like to consult your diagnostics - inline, in the fringe, or in a
dedicated buffer? I’d love to hear your thoughts in the comments!</p>

<p>That’s all I have for you today. Keep those errors in plain sight!</p>]]></content><author><name>Bozhidar Batsov</name></author><category term="Emacs 30" /><summary type="html"><![CDATA[If you’ve used modern editors like VS Code, you’ve probably noticed how they display error and warning messages inline, right at the end of the offending line. It’s a nice touch - you don’t have to hover over a squiggly underline or check a separate diagnostics buffer to see what’s wrong. Emacs 30 brings this capability to Flymake with the new flymake-show-diagnostics-at-end-of-line option.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://emacsredux.com/assets/og-image.png" /><media:content medium="image" url="https://emacsredux.com/assets/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">which-key is Now Built-in</title><link href="https://emacsredux.com/blog/2026/07/18/which-key-is-now-built-in/" rel="alternate" type="text/html" title="which-key is Now Built-in" /><published>2026-07-18T07:00:00+00:00</published><updated>2026-07-18T07:00:00+00:00</updated><id>https://emacsredux.com/blog/2026/07/18/which-key-is-now-built-in</id><content type="html" xml:base="https://emacsredux.com/blog/2026/07/18/which-key-is-now-built-in/"><![CDATA[<p><code class="language-plaintext highlighter-rouge">which-key</code> is one of those packages I recommend to pretty much everyone -
newcomers and grizzled Emacs veterans alike. You start a key sequence like
<code class="language-plaintext highlighter-rouge">C-x</code>, pause for a moment, and it pops up a handy cheat sheet of every key that
can follow. I’ve had it in my config for ages, and I suspect a lot of you have
as well.</p>

<p>Here’s the good news - as of Emacs 30 you don’t need to install it anymore.
<code class="language-plaintext highlighter-rouge">which-key</code> is now a <strong>built-in package</strong>, so there’s one less thing to fetch
from MELPA when you set up Emacs on a fresh machine.</p>

<!--more-->

<h2 id="enabling-which-key">Enabling which-key</h2>

<p>Being built-in doesn’t mean it’s enabled by default, though. You still have to
turn it on explicitly:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nv">which-key-mode</span> <span class="mi">1</span><span class="p">)</span>
</code></pre></div></div>

<p>That’s the whole setup for most people. Now start any prefix key - <code class="language-plaintext highlighter-rouge">C-x</code>,
<code class="language-plaintext highlighter-rouge">C-c</code>, <code class="language-plaintext highlighter-rouge">C-h</code> - wait a moment, and a popup appears at the bottom of the frame
listing every binding under that prefix.</p>

<p>Here’s what I get when I press <code class="language-plaintext highlighter-rouge">C-c p</code>, the prefix for
<a href="https://github.com/bbatsov/projectile">projectile</a>’s command map:</p>

<p><img src="/assets/images/which-key-projectile.png" alt="which-key showing projectile's C-c p command map" /></p>

<p>Instead of straining to remember whether it’s <code class="language-plaintext highlighter-rouge">C-c p f</code> or <code class="language-plaintext highlighter-rouge">C-c p s s</code>, I just
pause and Emacs reminds me. Projectile has a <em>lot</em> of commands, so which-key
even paginates them - notice the <code class="language-plaintext highlighter-rouge">1 of 3</code> in the bottom corner.</p>

<h2 id="configuration">Configuration</h2>

<p>The defaults are sensible, but here are the knobs I reach for most often:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">;; show the popup faster (the default is a full second)</span>
<span class="p">(</span><span class="k">setq</span> <span class="nv">which-key-idle-delay</span> <span class="mf">0.5</span><span class="p">)</span>

<span class="c1">;; where the popup shows up</span>
<span class="c1">;; options: side-window (default), minibuffer, frame, custom</span>
<span class="p">(</span><span class="k">setq</span> <span class="nv">which-key-popup-type</span> <span class="ss">'side-window</span><span class="p">)</span>

<span class="c1">;; and where that side window sits</span>
<span class="c1">;; options: bottom (default), top, left, right</span>
<span class="p">(</span><span class="k">setq</span> <span class="nv">which-key-side-window-location</span> <span class="ss">'bottom</span><span class="p">)</span>
</code></pre></div></div>

<p>I like a slightly snappier delay, but otherwise the stock configuration serves
me just fine.</p>

<h2 id="which-key-and-transient">which-key and Transient</h2>

<p>People sometimes ask me how <code class="language-plaintext highlighter-rouge">which-key</code> relates to
<a href="https://github.com/magit/transient">Transient</a> - the menu library that powers
Magit’s famous popups. The two look superficially similar (both drop a bunch of
keys and descriptions at the bottom of your frame), but they solve rather
different problems.</p>

<p><code class="language-plaintext highlighter-rouge">which-key</code> is a passive, automatic <em>reminder</em>. It doesn’t really know anything
about your commands - it simply reads whatever keymap you happen to be in and
shows you what’s there. You get it for free, across every prefix in Emacs, with
zero per-keymap work.</p>

<p>Transient is an interactive <em>command builder</em>. You design a transient
deliberately, for a particular workflow, and unlike which-key it can hold state</p>
<ul>
  <li>toggle switches on and off, accumulate arguments - before finally running a
command with all of that baggage attached.</li>
</ul>

<p>Projectile happens to ship both, which makes for a nice side-by-side. The
<code class="language-plaintext highlighter-rouge">C-c p</code> keymap you saw above is a plain keymap - which-key displays it and then
gets out of the way. But Projectile 3.0 also added <code class="language-plaintext highlighter-rouge">projectile-dispatch</code> (bound
to <code class="language-plaintext highlighter-rouge">C-c p m</code>), a Transient menu that mirrors the very same command map:</p>

<p><img src="/assets/images/projectile-dispatch.png" alt="The projectile-dispatch Transient menu" /></p>

<p>Notice the <code class="language-plaintext highlighter-rouge">Modifiers</code> section at the top - those are switches you flip <em>before</em>
picking a command. Want your next search to be case-sensitive, or your next
file lookup to invalidate the cache first? Toggle <code class="language-plaintext highlighter-rouge">-c</code> or <code class="language-plaintext highlighter-rouge">-i</code>, then press the
command key. That’s something a plain keymap (and therefore which-key) simply
can’t do.</p>

<p>So the way I see it - reach for which-key as an always-on safety net for the
thousands of bindings scattered across Emacs, and reach for Transient when
you’re building a polished, self-contained command center for a specific task.
They’re complementary, and there’s no reason not to run both. In fact, if you
use Magit or Projectile (or a dozen other modern packages), you’re already
using Transient whether you realized it or not.</p>

<h2 id="but-wait-what-about-c-h">But wait, what about C-h?</h2>

<p>Long-time Emacs users might point out that you’ve always been able to press
<code class="language-plaintext highlighter-rouge">C-h</code> after a prefix key to see the available bindings. That’s true! The
difference is that <code class="language-plaintext highlighter-rouge">which-key</code> does it <em>automatically</em>, no extra keypress
required - which makes it far more discoverable, especially for newcomers.</p>

<p>And the two don’t step on each other. <code class="language-plaintext highlighter-rouge">C-h</code> after a prefix still works and
gives you the traditional <code class="language-plaintext highlighter-rouge">describe-bindings</code> buffer, which you can scroll and
search to your heart’s content. Think of <code class="language-plaintext highlighter-rouge">which-key</code> as the quick glance and
<code class="language-plaintext highlighter-rouge">C-h</code> as the full reference.</p>

<h2 id="closing-thoughts">Closing Thoughts</h2>

<p>I’ve been a happy <code class="language-plaintext highlighter-rouge">which-key</code> user for years, and having it in the box means one
less package to install and keep updated. If you’ve somehow never tried it, do
yourself a favor and flip it on - it’s the kind of small quality-of-life feature
you stop noticing precisely because it’s always quietly helping you.</p>

<p>Do you keep which-key on all the time, or do you prefer to lean on <code class="language-plaintext highlighter-rouge">C-h</code>? And
have you started building your own Transient menus yet? I’d love to hear about
it in the comments.</p>

<p>That’s all I have for you today. Keep hacking (and let Emacs remember the keys
for you)!</p>]]></content><author><name>Bozhidar Batsov</name></author><category term="Emacs 30" /><category term="Built-ins" /><summary type="html"><![CDATA[which-key is one of those packages I recommend to pretty much everyone - newcomers and grizzled Emacs veterans alike. You start a key sequence like C-x, pause for a moment, and it pops up a handy cheat sheet of every key that can follow. I’ve had it in my config for ages, and I suspect a lot of you have as well. Here’s the good news - as of Emacs 30 you don’t need to install it anymore. which-key is now a built-in package, so there’s one less thing to fetch from MELPA when you set up Emacs on a fresh machine.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://emacsredux.com/assets/og-image.png" /><media:content medium="image" url="https://emacsredux.com/assets/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Tree-sitter Modes Still Need a Syntax Table</title><link href="https://emacsredux.com/blog/2026/07/17/tree-sitter-modes-still-need-a-syntax-table/" rel="alternate" type="text/html" title="Tree-sitter Modes Still Need a Syntax Table" /><published>2026-07-17T09:15:00+00:00</published><updated>2026-07-17T09:15:00+00:00</updated><id>https://emacsredux.com/blog/2026/07/17/tree-sitter-modes-still-need-a-syntax-table</id><content type="html" xml:base="https://emacsredux.com/blog/2026/07/17/tree-sitter-modes-still-need-a-syntax-table/"><![CDATA[<p>When you write a tree-sitter major mode, it’s tempting to think the
parser handles everything. It doesn’t. Tree-sitter drives font-lock,
indentation, and structural navigation, but a whole layer of everyday
Emacs behavior still runs on the humble <strong>syntax table</strong>: <code class="language-plaintext highlighter-rouge">forward-sexp</code>
and friends, <code class="language-plaintext highlighter-rouge">electric-pair-mode</code>, <code class="language-plaintext highlighter-rouge">delete-pair</code>, <code class="language-plaintext highlighter-rouge">forward-word</code>, and
anything built on <code class="language-plaintext highlighter-rouge">syntax-ppss</code>. (I wrote about that structural layer in
<a href="/blog/2026/06/20/essential-structured-navigation-and-editing-commands/">Essential Structured Navigation and Editing Commands</a>.)</p>

<p>I got a sharp reminder of this while building
<a href="https://github.com/bbatsov/neocaml">neocaml</a>, my tree-sitter mode for
OCaml. The grammar parsed everything beautifully, yet <code class="language-plaintext highlighter-rouge">delete-pair</code> and
sexp motion kept misbehaving around a couple of OCaml constructs. The
fix turned out to be a classic tool that long predates tree-sitter:
<code class="language-plaintext highlighter-rouge">syntax-propertize-function</code>. Here’s the story - it tripped me up for a
good while, so maybe it’ll spare you some head-scratching.</p>

<!--more-->

<h2 id="the-problem-characters-a-static-syntax-table-cant-classify">The problem: characters a static syntax table can’t classify</h2>

<p>A syntax table assigns each <em>character</em> a single class: this one opens a
string, that one is a comment starter, this is a word constituent. That
works until a character means different things in different places. OCaml
has two such troublemakers.</p>

<p><strong>Character literals.</strong> <code class="language-plaintext highlighter-rouge">'a'</code> is a character, and the single quotes
delimit it. But the same <code class="language-plaintext highlighter-rouge">'</code> also starts a <em>type variable</em> (<code class="language-plaintext highlighter-rouge">'a</code> in
<code class="language-plaintext highlighter-rouge">'a list</code>), and can appear inside identifiers as a prime (<code class="language-plaintext highlighter-rouge">x'</code>). So you
can’t just declare <code class="language-plaintext highlighter-rouge">'</code> a string delimiter. And if you leave it as a
symbol constituent (the usual choice), a character literal whose contents
happen to be a delimiter wreaks havoc:</p>

<div class="language-ocaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">let</span> <span class="n">x</span> <span class="o">=</span> <span class="k">'</span><span class="s2">"'   (* the "</span> <span class="n">opens</span> <span class="n">a</span> <span class="kt">string</span><span class="o">,</span> <span class="k">as</span> <span class="n">far</span> <span class="k">as</span> <span class="n">the</span> <span class="n">syntax</span> <span class="n">table</span> <span class="n">knows</span> <span class="o">*</span><span class="p">)</span>
<span class="k">let</span> <span class="n">y</span> <span class="o">=</span> <span class="k">'</span><span class="p">(</span><span class="k">'</span>   <span class="c">(* the ( is an unbalanced open paren *)</span>
</code></pre></div></div>

<p><strong>Quoted string literals.</strong> OCaml’s <code class="language-plaintext highlighter-rouge">{|...|}</code> (and tagged <code class="language-plaintext highlighter-rouge">{foo|...|foo}</code>)
raw strings can contain anything - including <code class="language-plaintext highlighter-rouge">"</code>, <code class="language-plaintext highlighter-rouge">(*</code>, and friends -
which the syntax table reads as real string/comment delimiters:</p>

<div class="language-ocaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">let</span> <span class="n">z</span> <span class="o">=</span> <span class="p">{</span><span class="o">|</span><span class="n">a</span> <span class="s2">"b"</span> <span class="c">(* not a comment *)</span><span class="o">|</span><span class="p">}</span>
</code></pre></div></div>

<p>You can <em>see</em> the damage with <code class="language-plaintext highlighter-rouge">syntax-ppss</code>. With nothing but a static
table, point at the end of <code class="language-plaintext highlighter-rouge">let x = '"'</code> reports that you’re inside a
string:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nb">nth</span> <span class="mi">3</span> <span class="p">(</span><span class="nv">syntax-ppss</span><span class="p">))</span>  <span class="c1">;; =&gt; 34   (i.e. inside a string opened by ")</span>
</code></pre></div></div>

<p>And every command that consults the syntax table inherits the confusion:
<code class="language-plaintext highlighter-rouge">C-M-f</code> walks off into nonsense, <code class="language-plaintext highlighter-rouge">delete-pair</code> grabs the wrong delimiter,
<code class="language-plaintext highlighter-rouge">electric-pair-mode</code> autopairs incorrectly.</p>

<p>Note that <em>font-lock</em> looks fine here - tree-sitter fontifies these
constructs correctly from the parse tree. That’s exactly what makes the
bug sneaky: the buffer looks right, but the syntactic layer underneath is
lying.</p>

<h2 id="the-fix-context-sensitive-syntax-with-syntax-propertize">The fix: context-sensitive syntax with <code class="language-plaintext highlighter-rouge">syntax-propertize</code></h2>

<p>The escape hatch is
<a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Properties.html"><code class="language-plaintext highlighter-rouge">syntax-propertize-function</code></a>:
a buffer-local function that runs lazily over regions of the buffer and
applies <code class="language-plaintext highlighter-rouge">syntax-table</code> <em>text properties</em> to override the static table
where context demands it. Because the properties are attached to specific
positions, <code class="language-plaintext highlighter-rouge">'</code> can be a string delimiter in <code class="language-plaintext highlighter-rouge">'a'</code> and an ordinary symbol
character in <code class="language-plaintext highlighter-rouge">'a list</code> - in the same buffer.</p>

<p>The usual way to write one is with <code class="language-plaintext highlighter-rouge">syntax-propertize-rules</code>, which maps
regexps to the syntax classes to apply to their capture groups. Here’s
the heart of neocaml’s:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nb">defun</span> <span class="nv">neocaml--syntax-propertize</span> <span class="p">(</span><span class="nv">start</span> <span class="nv">end</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">goto-char</span> <span class="nv">start</span><span class="p">)</span>
  <span class="p">(</span><span class="nb">funcall</span>
   <span class="p">(</span><span class="nv">syntax-propertize-rules</span>
    <span class="c1">;; Character literals: 'a', '\n', '"', '(', ...</span>
    <span class="c1">;; Mark both quotes as string delimiters so the contents are inert.</span>
    <span class="c1">;; A closing quote is required, so type variables ('a) are untouched.</span>
    <span class="p">(</span><span class="s">"\\_&lt;\\('\\)\\(?:[^'\\\n]\\|\\\\.[^\\'\n \")]*\\)\\('\\)"</span>
     <span class="p">(</span><span class="mi">1</span> <span class="s">"\""</span><span class="p">)</span> <span class="p">(</span><span class="mi">2</span> <span class="s">"\""</span><span class="p">))</span>
    <span class="c1">;; Quoted strings {tag|...|tag}: fence both ends so the body is inert.</span>
    <span class="p">(</span><span class="s">"\\({\\)\\([[:lower:]_]*\\)|"</span>
     <span class="p">(</span><span class="mi">1</span> <span class="p">(</span><span class="k">let*</span> <span class="p">((</span><span class="nv">tag</span> <span class="p">(</span><span class="nv">match-string</span> <span class="mi">2</span><span class="p">))</span>
               <span class="p">(</span><span class="nb">close</span> <span class="p">(</span><span class="nv">save-excursion</span>
                        <span class="p">(</span><span class="nb">when</span> <span class="p">(</span><span class="nv">search-forward</span> <span class="p">(</span><span class="nv">concat</span> <span class="s">"|"</span> <span class="nv">tag</span> <span class="s">"}"</span><span class="p">)</span> <span class="nv">end</span> <span class="no">t</span><span class="p">)</span>
                          <span class="p">(</span><span class="nv">point</span><span class="p">)))))</span>
          <span class="p">(</span><span class="nb">when</span> <span class="nb">close</span>
            <span class="p">(</span><span class="nv">put-text-property</span> <span class="p">(</span><span class="nb">1-</span> <span class="nb">close</span><span class="p">)</span> <span class="nb">close</span>
                               <span class="ss">'syntax-table</span> <span class="p">(</span><span class="nv">string-to-syntax</span> <span class="s">"|"</span><span class="p">)))</span>
          <span class="p">(</span><span class="nv">string-to-syntax</span> <span class="s">"|"</span><span class="p">)))))</span>
   <span class="p">(</span><span class="nv">point</span><span class="p">)</span> <span class="nv">end</span><span class="p">))</span>
</code></pre></div></div>

<p>and you install it in the mode body:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nv">setq-local</span> <span class="nv">syntax-propertize-function</span> <span class="nf">#'</span><span class="nv">neocaml--syntax-propertize</span><span class="p">)</span>
</code></pre></div></div>

<p>Two kinds of rules are at work:</p>

<ul>
  <li>The <em>character literal</em> rule matches a complete <code class="language-plaintext highlighter-rouge">'...'</code> and gives both
quotes string-quote syntax (<code class="language-plaintext highlighter-rouge">"</code>). The contents then sit <em>inside a
string</em> as far as the scanner is concerned, so an inner <code class="language-plaintext highlighter-rouge">"</code> or <code class="language-plaintext highlighter-rouge">(</code> is
inert. Crucially, the regexp requires a <em>closing</em> quote, so a bare
<code class="language-plaintext highlighter-rouge">'a</code> type variable never matches and keeps its symbol syntax.</li>
  <li>The <em>quoted string</em> rule matches the opening <code class="language-plaintext highlighter-rouge">{tag|</code>, searches for the
matching <code class="language-plaintext highlighter-rouge">|tag}</code>, and marks both the opening and closing delimiters with
<em>generic string fence</em> syntax (<code class="language-plaintext highlighter-rouge">|</code>). Everything between two fences is a
string, so embedded quotes and comment starters are neutralized.</li>
</ul>

<p>With that in place, <code class="language-plaintext highlighter-rouge">syntax-ppss</code> tells the truth again, and <code class="language-plaintext highlighter-rouge">C-M-f</code>,
<code class="language-plaintext highlighter-rouge">delete-pair</code>, and <code class="language-plaintext highlighter-rouge">electric-pair-mode</code> all behave - including for the
<code class="language-plaintext highlighter-rouge">delete-pair</code> corner case I <a href="/blog/2026/03/14/removing-paired-delimiters-in-emacs/">wrote about earlier</a>.</p>

<h2 id="lessons-for-mode-writers">Lessons for mode writers</h2>

<p>A few things worth keeping in mind, whether or not you touch OCaml:</p>

<ul>
  <li>Tree-sitter and the syntax table are different layers. The parser
handles font-lock and structural queries, while the syntax table handles
character-level motion and pairing. A great grammar doesn’t save you
from getting the syntax table right. (See also
<a href="/blog/2026/03/08/customizing-font-lock-in-the-age-of-tree-sitter/">Customizing Font-Lock in the Age of Tree-sitter</a>.)</li>
  <li>Reach for <code class="language-plaintext highlighter-rouge">syntax-propertize</code> whenever a character’s role depends on
context - raw strings, here-docs, regex literals, character literals,
JSX, anything a single syntax class can’t capture. It’s exactly what
<code class="language-plaintext highlighter-rouge">rust-ts-mode</code> and <code class="language-plaintext highlighter-rouge">c-ts-mode</code> reach for, too.</li>
  <li>The syntax-table text properties don’t affect tree-sitter font-lock.
They live on a separate channel, so you can fix the syntactic layer
without disturbing your carefully tuned highlighting.</li>
  <li>Don’t call <code class="language-plaintext highlighter-rouge">syntax-ppss</code> from inside your <code class="language-plaintext highlighter-rouge">syntax-propertize-function</code>.
It’s re-entrant (<code class="language-plaintext highlighter-rouge">syntax-propertize</code> is itself driven by <code class="language-plaintext highlighter-rouge">syntax-ppss</code>)
and a fragile source of subtle bugs. Match constructs whole from their
opening delimiter instead, as the quoted-string rule above does, rather
than asking “am I currently inside a string?”.</li>
  <li>Know your string classes. Class <code class="language-plaintext highlighter-rouge">"</code> (string quote) is delimited by the
<em>same</em> character, while class <code class="language-plaintext highlighter-rouge">|</code> (generic string fence) pairs up
independently of the specific character. The latter is handy for
multi-character or asymmetric delimiters like <code class="language-plaintext highlighter-rouge">{tag|</code> … <code class="language-plaintext highlighter-rouge">|tag}</code>.</li>
</ul>

<p>None of this is new - <code class="language-plaintext highlighter-rouge">syntax-propertize</code> has been the right answer since
Emacs 24. But it’s easy to forget it exists when you’re deep in
tree-sitter land, and the symptoms (movement and pairing going subtly
wrong while the colors look perfect) are puzzling until you remember which
layer owns what.</p>

<p>Have you run into this while writing your own tree-sitter modes? I’d love
to hear how you tamed the syntax table in the comments.</p>

<p>That’s all I have for you today. Keep those parens balanced!</p>]]></content><author><name>Bozhidar Batsov</name></author><category term="Tree-sitter" /><category term="Major Modes" /><summary type="html"><![CDATA[When you write a tree-sitter major mode, it’s tempting to think the parser handles everything. It doesn’t. Tree-sitter drives font-lock, indentation, and structural navigation, but a whole layer of everyday Emacs behavior still runs on the humble syntax table: forward-sexp and friends, electric-pair-mode, delete-pair, forward-word, and anything built on syntax-ppss. (I wrote about that structural layer in Essential Structured Navigation and Editing Commands.) I got a sharp reminder of this while building neocaml, my tree-sitter mode for OCaml. The grammar parsed everything beautifully, yet delete-pair and sexp motion kept misbehaving around a couple of OCaml constructs. The fix turned out to be a classic tool that long predates tree-sitter: syntax-propertize-function. Here’s the story - it tripped me up for a good while, so maybe it’ll spare you some head-scratching.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://emacsredux.com/assets/og-image.png" /><media:content medium="image" url="https://emacsredux.com/assets/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Inline Completion with completion-preview-mode</title><link href="https://emacsredux.com/blog/2026/07/17/inline-completion-with-completion-preview-mode/" rel="alternate" type="text/html" title="Inline Completion with completion-preview-mode" /><published>2026-07-17T08:45:00+00:00</published><updated>2026-07-17T08:45:00+00:00</updated><id>https://emacsredux.com/blog/2026/07/17/inline-completion-with-completion-preview-mode</id><content type="html" xml:base="https://emacsredux.com/blog/2026/07/17/inline-completion-with-completion-preview-mode/"><![CDATA[<p>As part of the ongoing overhaul of my <a href="https://github.com/bbatsov/emacs.d">Emacs setup</a>
I’ve been trying to make the most of the built-in functionality that recent Emacs
releases keep quietly shipping. My in-buffer completion setup is
<a href="/blog/2026/07/13/cape-corfus-best-friend/">based on <code class="language-plaintext highlighter-rouge">corfu</code> and <code class="language-plaintext highlighter-rouge">cape</code></a>
these days, but it turns out I had overlooked a nice Emacs 30 addition
in the same area - <code class="language-plaintext highlighter-rouge">completion-preview-mode</code>.
It gives you inline completion suggestions - the “ghost text” UI that GitHub
Copilot and friends made famous<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup> - except here it’s powered by plain old
Emacs completions.</p>

<!--more-->

<h2 id="what-it-does">What It Does</h2>

<p>As you type, <code class="language-plaintext highlighter-rouge">completion-preview-mode</code> shows a grayed-out preview of the top
completion candidate right after point - inline, in the buffer itself. No popup,
no minibuffer, no fuss. If the suggestion is what you want, press <code class="language-plaintext highlighter-rouge">TAB</code> to accept
it. If not, just keep typing and the preview updates (or goes away).</p>

<p><img src="/assets/images/completion-preview-ghost-text.png" alt="Ghost text suggesting the rest of a symbol as you type" /></p>

<p>The part I like best - the candidates come from <code class="language-plaintext highlighter-rouge">completion-at-point-functions</code>,
which means the preview is fed by the exact same backends as <code class="language-plaintext highlighter-rouge">corfu</code> and
<code class="language-plaintext highlighter-rouge">company</code>. If you’ve already set up <code class="language-plaintext highlighter-rouge">cape-dabbrev</code>, <code class="language-plaintext highlighter-rouge">cape-file</code> or <code class="language-plaintext highlighter-rouge">eglot</code>,
all of them power the ghost text automatically. Batteries very much included.</p>

<h2 id="enabling-it">Enabling It</h2>

<p>You can try it out in the current buffer with <code class="language-plaintext highlighter-rouge">M-x completion-preview-mode</code>.
If you like what you see, you can enable it everywhere:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nv">global-completion-preview-mode</span> <span class="mi">1</span><span class="p">)</span>
</code></pre></div></div>

<p>Here’s the relevant bit of my config:</p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nb">use-package</span> <span class="nv">completion-preview</span>
  <span class="ss">:ensure</span> <span class="no">nil</span> <span class="c1">; built-in</span>
  <span class="ss">:config</span>
  <span class="c1">;; cycle through the other candidates with M-n/M-p (those two</span>
  <span class="c1">;; commands have no default bindings)</span>
  <span class="p">(</span><span class="nv">define-key</span> <span class="nv">completion-preview-active-mode-map</span> <span class="p">(</span><span class="nv">kbd</span> <span class="s">"M-n"</span><span class="p">)</span> <span class="nf">#'</span><span class="nv">completion-preview-next-candidate</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">define-key</span> <span class="nv">completion-preview-active-mode-map</span> <span class="p">(</span><span class="nv">kbd</span> <span class="s">"M-p"</span><span class="p">)</span> <span class="nf">#'</span><span class="nv">completion-preview-prev-candidate</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">global-completion-preview-mode</span> <span class="mi">+1</span><span class="p">))</span>
</code></pre></div></div>

<h2 id="essential-keybindings">Essential Keybindings</h2>

<p>While a preview is visible you can make use of the following keybindings:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">TAB</code> (<code class="language-plaintext highlighter-rouge">completion-preview-insert</code>) - accept the suggested completion</li>
  <li><code class="language-plaintext highlighter-rouge">M-i</code> (<code class="language-plaintext highlighter-rouge">completion-preview-complete</code>) - insert only the longest common prefix
of all the candidates (the preview underlines it, so you know in advance what
you’ll get) and let you keep typing from there</li>
  <li><code class="language-plaintext highlighter-rouge">M-n</code> / <code class="language-plaintext highlighter-rouge">M-p</code> (<code class="language-plaintext highlighter-rouge">completion-preview-next-candidate</code> / <code class="language-plaintext highlighter-rouge">completion-preview-prev-candidate</code>) -
cycle through the other candidates; those are not bound by default, but the
docs themselves suggest <code class="language-plaintext highlighter-rouge">M-n</code> and <code class="language-plaintext highlighter-rouge">M-p</code> (see my config above)</li>
</ul>

<p>Here’s <code class="language-plaintext highlighter-rouge">M-i</code> in action. I had typed <code class="language-plaintext highlighter-rouge">my-pro</code>, and pressing <code class="language-plaintext highlighter-rouge">M-i</code> filled in
<code class="language-plaintext highlighter-rouge">ject-find-</code>, stopping exactly where the two candidates (<code class="language-plaintext highlighter-rouge">my-project-find-file</code>
and <code class="language-plaintext highlighter-rouge">my-project-find-dir</code>) diverge:</p>

<p><img src="/assets/images/completion-preview-common-prefix.png" alt="M-i completes up to the longest common prefix of the candidates" /></p>

<p>And when you cycle with <code class="language-plaintext highlighter-rouge">M-n</code>, Emacs even tells you where you are in the
candidate list in the echo area:</p>

<p><img src="/assets/images/completion-preview-cycling.png" alt="Cycling through the completion candidates with M-n" /></p>

<p>There’s basic mouse support as well - clicking the ghost text with <code class="language-plaintext highlighter-rouge">mouse-1</code>
inserts it, and scrolling the mouse wheel over it cycles through the candidates.
(I doubt I’ll ever use that, but it’s kind of cute)</p>

<h2 id="fine-tuning">Fine-tuning</h2>

<p>A few user options to adjust the behavior:<sup id="fnref:2" role="doc-noteref"><a href="#fn:2" class="footnote" rel="footnote">2</a></sup></p>

<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">;; show the preview only after typing at least 3 characters (the default)</span>
<span class="p">(</span><span class="nv">setopt</span> <span class="nv">completion-preview-minimum-symbol-length</span> <span class="mi">3</span><span class="p">)</span>

<span class="c1">;; wait a bit before showing the preview (by default it shows up instantly)</span>
<span class="p">(</span><span class="nv">setopt</span> <span class="nv">completion-preview-idle-delay</span> <span class="mf">0.2</span><span class="p">)</span>

<span class="c1">;; show a preview only when there's exactly one candidate</span>
<span class="p">(</span><span class="nv">setopt</span> <span class="nv">completion-preview-exact-match-only</span> <span class="no">t</span><span class="p">)</span>
</code></pre></div></div>

<p>There’s also <code class="language-plaintext highlighter-rouge">completion-preview-commands</code> - the list of commands after which
the preview appears (things like <code class="language-plaintext highlighter-rouge">self-insert-command</code>). You’ll rarely need to
touch it, but it’s good to know it’s there if some command you use doesn’t
trigger the preview.</p>

<h2 id="do-you-still-need-corfu">Do You Still Need Corfu?</h2>

<p>When I first read about <code class="language-plaintext highlighter-rouge">completion-preview-mode</code> I assumed it was competing
with <code class="language-plaintext highlighter-rouge">corfu</code> and <code class="language-plaintext highlighter-rouge">company</code>, but I’ve come to think that’s the wrong way to look
at it. They draw candidates from the same source and simply present them
differently - <code class="language-plaintext highlighter-rouge">corfu</code> gives you the full candidate list with annotations and
documentation, while the preview gives you the single most likely candidate
with zero visual ceremony. These days I run both: the ghost text handles the
“obviously I meant that symbol” cases with a single <code class="language-plaintext highlighter-rouge">TAB</code>, and <code class="language-plaintext highlighter-rouge">corfu</code>’s popup
kicks in when I actually need to browse.</p>

<p>Admittedly, two completion UIs at once won’t be everyone’s cup of tea. If you
find it too busy, a nice middle ground is to enable <code class="language-plaintext highlighter-rouge">completion-preview-mode</code>
only where a popup feels out of place - e.g. in <code class="language-plaintext highlighter-rouge">eshell-mode</code> or <code class="language-plaintext highlighter-rouge">comint-mode</code>
buffers.</p>

<h2 id="closing-thoughts">Closing Thoughts</h2>

<p>Emacs 30 keeps chipping away at my list of third-party packages - <code class="language-plaintext highlighter-rouge">which-key</code>
and EditorConfig support are now built-in, and <code class="language-plaintext highlighter-rouge">completion-preview-mode</code>
covers a niche I didn’t even know I wanted covered. Not bad for a “boring”
stable release!</p>

<p>Have you tried <code class="language-plaintext highlighter-rouge">completion-preview-mode</code> already? Are you a ghost text person
or a popup person? (or both, like me) I’d love to hear your thoughts in the
comments!</p>

<p>That’s all I have for you today. Keep completing!</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1" role="doc-endnote">
      <p>Unlike the AI assistants, the suggestions here come straight from your
buffers and your <code class="language-plaintext highlighter-rouge">completion-at-point-functions</code>. No subscription needed
and no hallucinations included. <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:2" role="doc-endnote">
      <p>If you’re wondering what’s this <code class="language-plaintext highlighter-rouge">setopt</code> thing - check out
<a href="/blog/2025/04/06/goodbye-setq-hello-setopt/">this article</a>. <a href="#fnref:2" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Bozhidar Batsov</name></author><category term="Emacs 30" /><category term="Built-ins" /><summary type="html"><![CDATA[As part of the ongoing overhaul of my Emacs setup I’ve been trying to make the most of the built-in functionality that recent Emacs releases keep quietly shipping. My in-buffer completion setup is based on corfu and cape these days, but it turns out I had overlooked a nice Emacs 30 addition in the same area - completion-preview-mode. It gives you inline completion suggestions - the “ghost text” UI that GitHub Copilot and friends made famous1 - except here it’s powered by plain old Emacs completions. Unlike the AI assistants, the suggestions here come straight from your &#8617;]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://emacsredux.com/assets/og-image.png" /><media:content medium="image" url="https://emacsredux.com/assets/og-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>