Emacs By Macros 6

Sahas Subramanian is back with another excellent episode of learning Emacs through keyboard macros. This video covers editing macros to correct or change a macro without starting over. If you have a long and complicated macro, that can be a real win.

He begins by showing how you can add some instructions to the last macro by simply calling kmacro-start-macro (usually bound to Ctrl+x ( or F3) with the universal argument. That can be useful but the real power comes from calling edit-last-kbd-macro. That brings up a buffer of the keystroke in the last macro and lets you edit them to correct errors or add or delete keystrokes. The nice thing about edit-last-kbd-macro is that there’s nothing to remember other than the name of the command so you can easily use it even though you probably won’t have the opportunity very often.

The video starts with Subramanian using occur to locate the function definitions in a C++ file. That’s tricky, of course, so the video provides an amusing real life example of building and correcting complex regular expressions. As I said last time, almost everyone watching Subramanian’s videos is going to bring experience with another editor with them so the idea regular expressions will be familiar and the video serves as a partial explanation of Emacs’ regular expression peculiarities.

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