What you want is
(global-set-key (kbd "C-<f1>")
(lambda () (interactive)
(load-theme 'zenburn t)))
The problem was that global-set-key
expects a "command", meaning a function (defined, say, with defun
or lambda
) with the additional magic form (interactive)
added after the arguments list, which tells Emacs that the function is meant to be invoked by the user. The interactive
form takes optional arguments specifying, for example, whether your command should prompt for options in the minibuffer, and so forth.
Your'(load-theme 'zenburn)
is not a command, or even a function; it's just arbitrary data (equivalent to the result of running (list 'load-theme (list 'quote 'zenburn)
. Hence the error.
Note also that, since we trust zenburn, we're also applying t
as the third argument to load-theme
. Otherwise we'll be prompted to mark the theme as safe.