What is wrong with the following code:
(defun test
(interactive)
(message "hello"))
(global-set-key '[f4] 'test)
When evaluating this with eval-region
and then pressing F4 I get the error:
Wrong type argument: commandp, test
You are missing the argument list of your test
function, so Emacs interprets the (interactive)
form as the arglist. Thus you have defined a non-interactive function of 1 argument instead of interactive command of no arguments.
What you want is:
(defun test ()
"My command test"
(interactive)
(message "hello"))
Lessons learned:
elint
(comes with Emacs, try C-h a elint RET).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With