An Example Of A Emacs Keyboard Macro

Jeremy Friesen has an interesting example of using an Emacs keyboard macro. What makes it interesting is that the macro deals with three files, switching between them as needed. The problem he was solving, as I understand it, was to add certain metadata to two versions of a series of files. The third file held links to the entries in the other files.

There are two takeaways from the post for me. The first, most obviously, is using a keyboard macro to capture a routine but error prone process so it can be performed easily and without error. The macro is actually straightforward even though it is dealing with three files.

The second takeaway is a bit more controversial. This process is needed because Friesen publishes his blog with Hugo but writes his posts with Org mode. After writing them in Org he exports the Org file to markdown with Ox-Hugo and uses the markdown file for the actual publishing.

This, it seems to me, is a process begging for some refactoring. Believe me, I understand why he hasn’t done so. Long time readers will remember the many times I finally got around to fixing some overly complicated process in my own workflow and wondered in print why it took me so long.

At the very least, I would automate the Org mode → Hugo publishable file pipeline and keep only the Org file. A better solution is to find a publishing workflow that accepts Org files to begin with. I vaguely recall that someone (Mike Zamansky?) discovered a way to use Org files directly with Hugo. Even in the likely event that I’m misremembering, there are certainly other static site generators that accept Org files.

I’m confident that Friesen will eventually optimize this process just as I eventually get around to optimizing mine. In the mean time, his post is a good example of using keyboard macros to automate a tedious and error prone process.

UPDATE [2024-01-08 Mon 11:20]: Added link to Friesen’s post.

This entry was posted in General and tagged , . Bookmark the permalink.