I have been creating macros and saving them for later use with the following process.
- Create keyboard macro
- Edit the macro:
C-x C-k C-e - Name the macro:
M-x name-last-kbd-macro - Create an .el file then insert the macro definition:
M-x insert-kbd-macro
With the lisp code saved for later, I’ll load it up in my .emacs file. Perhaps it is my unfamiliarity with elisp, but the elisp code which is generated seems quite unwieldy. I much prefer the syntax in the macro editor, and I’d like to make updates and refinements to the code that I’ve created, so I ask:
Is there a way to take my elisp code back to a reasonable rendition in the macro editor?
You can use
C-x C-k e M-xfollowed by the name of the macro you want to edit. (OrC-x C-k e(edit-kbd-macro) followed by the key sequence a macro is bound to;M-xhere is just a kind of mnemonic, as the help for the command explains).Maybe it’s also helpful to know that all the keyboard macros you’ve run are saved in a global ring, so you can cycle backwards and forwards through them using
C-x C-k C-nandC-x C-k C-p.BTW, it’s not just unfamiliarity with Elisp that makes those macro definitions hard to read;
insert-kbd-macrobasically just writes out the macro as a vector of key sequences. Elisp written by humans is a much pleasanter language 😉