The doc of execute-kbd-macro says:

(execute-kbd-macro MACRO &optional COUNT LOOPFUNC)
If MACRO is a symbol, its function definition is used.

I tried M-: (execute-kbd-macro 'ignore). That bailed out with the following error message:

Keyboard macros must be strings or vectors

That happens with emacs-version GNU Emacs 26.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2019-04-12.

Is that an Emacs bug, a documentation bug, or do I misunderstand something?

Might it be that the function definition of the symbol must be a keyboard macro? At least the following code works:

(fset 'a (kbd "myfun"))
(execute-kbd-macro 'a)

Background: I wanted to use apply-macro-to-region-lines on a command in an answer about applying comment-indent on a region.

  • Looks like a bug to me. I think they wanted Findirect_function rather than indirect_function in that code.
    – wvxvw
    Jul 18, 2019 at 9:48


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.