Skip to main content
explain third arg of load-theme
Source Link

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.

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.

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.

Source Link

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.