I am getting a "Wrong type argument: commandp, (lambda nil (forward-line 5))" here.
(global-set-key [?\M-n] '(lambda () (forward-line 5)))
What is the error? I'm fairly sure it's simple & I'm missing something obvious.
I am getting a "Wrong type argument: commandp, (lambda nil (forward-line 5))" here.
(global-set-key [?\M-n] '(lambda () (forward-line 5)))
What is the error? I'm fairly sure it's simple & I'm missing something obvious.
global-set-key
expects an interactive command. '(lambda () (interactive) (forward-line 5))
ought to work.
By the way, C-h f commandp
is a pretty good starting point for errors like that.
The correct form should be this -
(global-set-key (kbd "M-n") '(lambda () (interactive) (forward-line 5)))
The problem was that you forgot to put (interactive)
(as brendan mentioned).
By the way, you will notice that I used the (kbd)
function for specifying the key-binding. That function is immensely useful since you can put the key-bindings almost literally.
As a side note: when you quote the anonymous function like that it won't be compiled. I imagine it's no big deal in your case, though.