Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: getting readable keyboard-macros

When using insert-kbd-macro to save a named keyboard macro I get "unreadable" Lisp code like

(fset 'ppsql
   (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([134217788 134217765 44 return 44 17 10 return 33 134217765 102 102 backspace 114 111 109 return 17 10 102 111 109 backspace backspace 114 111 return 33] 0 "%d")) arg)))

I'd rather have something like the following:

(fset 'move-line-down
      [?\C-a ?\C-k delete down ?\C-y return up])

IIRC I used the same method to record, name, and insert both keyboard macros: F3, F4, name-last-kbd-macro.

Is it possible to get the first macro in a readable format?

like image 214
steglig Avatar asked Apr 15 '09 20:04

steglig


People also ask

How to record a macro in Emacs?

In order to start recording Emacs keyboard macros you only have to press the <f3> key on your keyboard. The next series of keyboard input commands you use will be recorded in memory. When you have finished the repeatable sequence of keys, press the <f4> key.

Can you save macros on keyboard?

Using a “load-file” Function This means you can store your keyboard macros in any file you want and load them via a function in your init file.

How do I repeat a macro in Emacs?

Immediately after typing C-x e , you can type e repeatedly to immediately repeat the macro one or more times. You can also give C-x e a repeat argument, just like F4 (when it is used to execute a macro). C-x ) can be given a repeat count as an argument. This means to repeat the macro right after defining it.


1 Answers

The keyboard macro functionality in Emacs stands of two modes: macros and kmacros. The former returns the macro in a way you like—the symbol form—, the latter provides the lambda form. So that, if you call name-last-kbd-macro you get a symbol form, if you call kmacro-name-last-macro, you get a lambda form.

like image 186
viam0Zah Avatar answered Sep 24 '22 07:09

viam0Zah