.emacs global-set-key and calling interactive function with argument

global-set-key only takes 2 arguments: the key sequence and the command you want to bind to it. So

(global-set-key (kbd "M-<down>") 'move-line)

works fine. But if you want to use move-line with an argument you need to wrap it in an anonymous (aka lamba) function so that it presents itself to global-set-key as one value.


Not minutes after asking the question I figured it out by copy+pasting code. However I have no clue how it works.

(global-set-key (kbd "M-<up>") (lambda () (interactive) (move-line -1)))

Tags:

Emacs

Elisp