RSSAmplifier

tommorris.org · Apr 26, 2025

TIL: track changes in Emacs with highlight-changes-mode

0
Sign in to vote or save

tommorris.org

I find myself having to review and edit a lot of plain text. You’d think a “bicycle for the mind” could make this better.

Non-programmers have Word’s Tracked Changes. Or the Google Docs equivalent. The point of this is if Person A wrote a document, and sent it to Person B for review, Person B could make a bunch of changes, then send it back to Person A.

Programmers, meanwhile, have tools that are… more sophisticated? Like diff for one. Both Vim and Emacs have much more sophisticated versions of undo/redo, and tooling like undo-fu because that complexity can be a lot. Plus we have version control systems like Git (or even fancier stuff like Jujutsu which I can’t get on with). If you have the self-discipline and/or tooling to commit lots of little “wip: refactored” changes, you can then use rebase -i, cherry-pick and friends to stitch all those little scraps into a beautiful series of atomic commits that tell a lovely story for both your future self and others. Or git commit -am "did stuff" and embrace the chaos demon. But version control is perhaps over-the-top for drafting emails, blog posts and the like.

(If you’re vibe coding, feel free to disregard. Version control is completely optional, and it’s way funnier not to use it.)

If you write lots of prose, you (or a hallucinating chatbot acting on your behalf) frequently cranks out a crappy first version, or a rough outline, and then you want to go through and polish it meticulously until it doesn’t suck. When doing this, you want to make sure you’ve properly edited everything. If you’ve been noodling around in the intro, then get distracted and pootle around elsewhere, you might entirely skip doing anything about entire paragraphs. In the early days of word procesing, one often printed out the first draft, grabbed a red pen to review it methodically, then returned to the computer to make the edits. While doing this, you could obviously tick off each paragraph after you’ve reviewed it. As previously noted, I see great merit in taking notes by hand, and so, yes, great if you can. But that means you have to use printers which are cursed. And it is a lot of faff, so you often can’t.

The print-it-out-then-redline-it method is what Tracked Changes reimplements electronically, but Tracked Changes seems to have a baked-in assumption that the person doing the reviewing is separate from the person who wrote it. Which is often the case in a corporate environment… but often not the case. Also, I don’t wanna use Word or Word clones because plain text is good.

What I want then is a way to visually see “what have I changed?” as I’m editing a document.

Enter Emacs highlight-changes-mode.

Open a buffer in Emacs. Type M-x highlight-changes-mode. Start editing. The text you change will be highlighted. The text you don’t change won’t be. If you delete some text, the closest character will be marked with a delete symbol. By default, the changed text is coloured red, and the delete symbol is an underscore.

If you M-x highlight-changes-mode again, the change markers go away.

I found the default red to be a bit over-the-top, and would rather have the change applied to the background rather than the text itself (also, avoids affecting syntax highlighting). I picked a colour that better matched my preferences and theme.

(custom-set-faces!
  '(highlight-changes
    :foreground nil
    :background "#004272")
  '(highlight-changes-delete
    :underline t
    :foreground nil
    :background "#004272"))

Highlight Changes mode does some other stuff too—you can have it cycle through multiple colours, and distinguish between saved and unsaved changes. You can bounce around between bits of the text that you’ve changed and bits you haven’t. I’m not sure I need that… yet. The EmacsWiki has some other fun stuff about how people have used highlight changes, along with some grumpiness about the choice of colours.

Read the original on tommorris.org

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.