Elisp interactive function name

前端 未结 2 1346
南笙
南笙 2021-01-23 12:14

I\'m trying to use the interactive function name feature. On emacs lisp manual it says:

‘a’ A function name (i.e., a symbol satisfying fboundp). Existing, Completion, Pr

相关标签:
2条回答
  • 2021-01-23 12:51

    This should do this trick:

    (defun test (abcd)
      (interactive "aTheme name: ")
      (call-interactively abcd))
    
    0 讨论(0)
  • 2021-01-23 13:03

    Your function test receives its argument abcd as a function, but you can't just invoke a function by putting a symbol referencing it in the first position of a list to be evaluated. Since Emacs Lisp is a Lisp-2, the reference to the function provided to the interactive query is stored in symbol abcd's value slot, not its function slot. The evaluation rules for a list like

    (abcd)
    

    involve looking in the first object's function slot if that object is a symbol, which it is in your case. If instead you wish to invoke a function referenced in a symbol's value slot, you need the funcall function:

    (funcall abcd)
    

    That says, "Take abcd, grab the value out of its value slot, and, provided it's a function, call it here, just as we would have if that function had been referenced in the list's first position either in a symbol's function slot or by a direct reference to the function object."

    Here's an answer to a similar question with references useful to allow you probe further.

    0 讨论(0)
提交回复
热议问题