Next: , Previous: , Up: Miscellaneous  


Q5.1.3: Could you explain read-kbd-macro in more detail?

The read-kbd-macro function returns the internal Emacs representation of a human-readable string (which is its argument). Thus:

(read-kbd-macro "C-c C-a")
⇒ [(control ?c) (control ?a)]

(read-kbd-macro "C-c C-. <up>")
⇒ [(control ?c) (control ?.) up]

In GNU Emacs the same forms will be evaluated to what GNU Emacs understands internally—the sequences "\C-x\C-c" and [3 67108910 up], respectively.

The exact human-readable syntax is defined in the docstring of edmacro-mode. I’ll repeat it here, for completeness.

Format of keyboard macros during editing:

Text is divided into words separated by whitespace. Except for the words described below, the characters of each word go directly as characters of the macro. The whitespace that separates words is ignored. Whitespace in the macro must be written explicitly, as in foo SPC bar RET.

Any word may be prefixed by a multiplier in the form of a decimal number and *: 3*<right><right> <right> <right>, and 10*foofoofoofoofoofoofoofoofoofoofoo.

Multiple text keys can normally be strung together to form a word, but you may need to add whitespace if the word would look like one of the above notations: ; ; ; is a keyboard macro with three semicolons, but ;;; is a comment. Likewise, \ 1 2 3 is four keys but \123 is a single key written in octal, and < right > is seven keys but <right> is a single function key. When in doubt, use whitespace.


Next: , Previous: , Up: Miscellaneous