views:

242

answers:

3

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 kbd-macros: F3, F4, name-last-kbd-macro.

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

A: 

I've never seen the first form. The second form is what I'm used to. Did you try re-recording the first macro to see what happens if you're sure you record, then name, then insert?

The other thing to try is "C-X (", which invokes kmacro-start-macro and "C-X )" kmacro-end-macro, rather than F3/F4,which are doing something extraneous about keeping a counter. Maybe the simpler keyboard macro command will work more straightforwardly.

PanCrit
+3  A: 

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.

Török Gábor
A: 

Thanks for that!

So the naming of the macro determines the format when inserting?

I've conducted some more experiments and noticed that M-x insert-kbd-macro RET RET would give me the "symbol-form".

Whereas M-x insert-kbd-macro RET pp2sql RET gives the "labmda-form" (after naming with name-last-kbd-macro).

Now I realize that I've all the way used name-last-kbd-macro in my earlier experiments...?

steglig
When you check the function definition of `kmacro-name-last-macro` (`C-h f kmacro-name-last-macro`), you will see in the last line that it calls `kmacro-lambda-form` on the macro--that's why you get the lambda form.(Next time better edit your question then post a new answer.)
Török Gábor