A Simple Macro

I’ve just had another of my occasional workflow epiphanies where I suddenly realize that some tedious routine task I regularly perform could easily be automated. In this case, only partially automated but one step at a time.

Everyday, I take a measurement and record the result in a notebook1. Every other Sunday I copy the measurements from my notebook into a file. I’ve been maintaining that file since before I started using Emacs so it doesn’t follow the conventions that I use now. In particular, each entry has a date with the format mm/dd/yy.

It’s really a pain to enter those dates. I realized that I could easily use a macro to enter them. My idea was to put the dd value in a macro counter and let the macro increment it for me for each new entry. Here’s my new procedure:

  • I use Ctrl+x Ctrl+k Ctrl+f to set the counter format to %02d so that each dd entry will be exactly two digits.
  • I use Ctrl+x Ctrl+k Ctrl+c to set the counter to the day number of the first entry’s date.
  • I define the macro by pressing F3 mm/ Ctrl+x Ctrl+k Ctrl+i to enter the day number, and then finish the macro with /yy F4.

It seems like a small thing but it really makes entering the data easier. Of course, what I actually thought was that I should write a function to do the date automatically but dealing with dates is a pain and what’s really needed here is a closure so that subsequent dates can be returned. That’s possible and I may do it eventually, but in the meantime, the macro is a big improvement.

Afternote

After I wrote this, Marcin Borkowski wrote a nice post on using keyboard macros that reminded me that you can use F3 instead of Ctrl+x Ctrl+k Ctrl+i to insert the counter value. I use counters in keyboard macros so seldomly that I’d forgotten that.

Footnotes:

1

Don’t ask. It’s my sole remaining use of pencil & paper for record keeping.

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