Next: , Previous: , Up: Keyboard Macros   [Contents][Index]

19.6 Editing a Keyboard Macro

C-x C-k C-e

Edit the last defined keyboard macro (kmacro-edit-macro).

C-x C-k e name RET

Edit a previously defined keyboard macro name (edit-kbd-macro).

C-x C-k l

Edit the last 300 keystrokes as a keyboard macro (kmacro-edit-lossage).

You can edit the last keyboard macro by typing C-x C-k C-e or C-x C-k RET (kmacro-edit-macro). This formats the macro definition in a buffer and enters a specialized major mode for editing it. Type C-h m once in that buffer to display details of how to edit the macro. When you are finished editing, type C-c C-c.

edmacro-mode, the major mode used by kmacro-edit-macro, provides commands for more easily editing the formatted macro. Use C-c C-q (edmacro-insert-key) to insert the next key sequence that you type into the buffer using the correct format, similar to C-q (quoted-insert). Use C-c C-r (edmacro-set-macro-to-region-lines) to replace the macro’s text with the text in the region. If the region does not begin at the start of a line or if it does not end at the end of a line, the region is extended to include complete lines. If the region ends at the beginning of a line, that final line is excluded.

You can edit a named keyboard macro or a macro bound to a key by typing C-x C-k e (edit-kbd-macro). Follow that with the keyboard input that you would use to invoke the macro—C-x e or M-x name or some other key sequence.

You can edit the last 300 keystrokes as a macro by typing C-x C-k l (kmacro-edit-lossage). By default, your most recent keystrokes are listed at the bottom of the buffer. To list a macro’s key sequences in reverse order, set edmacro-reverse-macro-lines to t.

Next: Stepwise Editing a Keyboard Macro, Previous: Naming and Saving Keyboard Macros, Up: Keyboard Macros   [Contents][Index]