Staying sane with Emacs (when facing drudge work)

I have to sift through 6 really boring config files. To stay sane, I call in Emacs for support.

My task looks like this:

img
(click for full size)

In the lower left window I check the identifier in the table I have to complete (left column), then I search for all instances of that identifier in the right window and insert the instrument type, the SIGMA (uncertainty due to representation error defined for the type of the instrument and the location of the site) and note whether the site is marked as assimilated in the config file.

Then I also check all the other config files and note whether the site is assimilated there.

Drudge work. There are people who can do this kind of work. My wife would likely be able to do it faster without tool support than I can do it with tool support. But I’m really bad at that: When the task gets too boring I tend to get distracted - for example by writing this article.

To get the task done anyway, I create tools which make it more enjoyable. And with Emacs that’s actually quite easy, because Emacs provides most required tools out of the box.

Firstoff: My workflow before adding tools was like this:

  • hit xo to switch from the lower left window to the config file at the right.
  • Use M-x occur then type the station identifier. This displays all occurances of the station identifier within the config file in the upper left window.
  • Hit xo twice to switch to the lower left window again.
  • Type the information into the file.
  • Switch to the next line and repeat the process.

I now want to simplify this to a single command per line. I’ll use F9 as key, because that isn’t yet used for other things in my Emacs setup and because it is easy to reach and my default keybinding as “useful shortcut for this file”. Other single-keystroke options would be F7 and F8. All other F-keys are already used :)

To make this easy, I define a macro:

  • Move to the line above the line I want to edit.
  • Start Macro-recording with C-x C-(.
  • Go to the beginning of the next line with C-n and C-a.
  • Activate the mark with C-SPACE and select the whole identifier with M-f.
  • Make the identifier lowercase with M-x downcase-region, copy it with M-w and undo the downcasing with C-x u (or use the undo key; I defined one in my xmodmap).
  • Switch to the config file with C-x o
  • Search the buffer with M-x occur, inserting the identifier with C-y.
  • Hit C-x o C-x o (yes, twice) to get back into the list of sites.
  • Move to the end of the instrument column with M-f and kill the word with C-BACKSPACE.
  • Save the macro with C-x C-).
  • Bind kmacro-call-macro to F9 with M-x local-set-key F9 kmacro-call-macro.

Done.

My workflow is now reduced to this:

  • Hit F9
  • Type the information.
  • Repeat.

I’m pretty sure that this will save me more time today than I spent writing this text ☺

Happy hacking!

AnhangGröße
2015-01-26-sane-with-emacs-task.png79.85 KB
2015-01-26-sane-with-emacs-task-200.png7.79 KB
2015-01-26-sane-with-emacs-task-300.png15.92 KB
2015-01-26-sane-with-emacs-task-400.png27.28 KB
2015-01-26-sane-with-emacs-task-450.png33.83 KB
Inhalt abgleichen
Willkommen im Weltenwald!
((λ()'Dr.ArneBab))



Beliebte Inhalte

sn.1w6.org news