Adding a Previously Defined Macro to a Macro Ring in Emacs

I use kmacro commands, such as kmacro-name-last-macroto save keyboard macros. The problem is that after I saved the macro and even added it to the .emacs file, I encounter an error and want to edit the macro using kmacro-step-edit-macro. If my named macro is no longer in the macro ring (the default kmacro-ring-maxis 8), I cannot use any editing commands or macros on this macro. Having learned that it will name-last-kbd-macropreserve the shape of the symbol, which is easier to edit, I regret to resort to using it kmacro-name-last-macroand wonder why this is new by default.

Is there a way to add a previously defined macro to a macro so that I can edit it with kmacro-step-edit-macro?

+3
source share
1 answer

Yes, there is a way to add a previously defined macro to the macro ring so you can edit it with kmacro-step-edit-macro:

Imagine you named the keyboard macro tata using name-last-kbd-macroand executed insert-kbd-macrofor tata. For instance:

(fset 'tata
   [return return ?f ?o ?o return])

You can save this macro definition in your .emacs for later use. In a new emacs session, you can use the following lisp code to return your macro to your kmacro ring:

(kmacro-push-ring (list 'tata 0 "%d"))
(kmacro-pop-ring)

After that you can do kmacro-step-edit-macroon it.

, kmacro-name-last-macro name-last-kbd-macro, insert-kbd-macro , ( ), :

(fset 'tata
   (lambda (&optional arg) "Keyboard macro." (interactive "p")
   (kmacro-exec-ring-item
      (quote ([return return 102 111 111 return] 0 "%d")) arg)))

kmacro-step-edit-macro , . , :

  • - (, tata ). .

  • , , : (fset 'foo [?\M-x ?t ?a ?t ?a return]) foo kmacro, . .

+3

Source: https://habr.com/ru/post/1763174/


All Articles