以下代码有什么问题:
(defun test
(interactive)
(message "hello"))
(global-set-key '[f4] 'test)
当我使用eval-region
命令并按下F4时,我收到以下错误:
Wrong type argument: commandp, test
以下代码有什么问题:
(defun test
(interactive)
(message "hello"))
(global-set-key '[f4] 'test)
当我使用eval-region
命令并按下F4时,我收到以下错误:
Wrong type argument: commandp, test
你的test
函数缺少参数列表,因此Emacs将(interactive)
表单解释为arglist。因此,你定义了一个带有1个参数的非交互函数,而不是没有参数的交互式命令。
你需要的是:
(defun test ()
"My command test"
(interactive)
(message "hello"))
经验教训:
elint
(随Emacs一起提供,尝试C-h a elint RET)。
(defun test () ...)
。 - uselpa