I'm a bloody beginner with lisp, so please bear with me.
I figure the best way to lean is to dive in. Because I'm setting up my Emacs environment, I'll edit my init.el
often, I wanted to add a hotkey to find it for editing quickly, as I'll need it often in the course of the next weeks.
I tried:
(global-set-key [f7] '(find-file "~/.emacs.d/init.el"))
to no avail, the answer when pressing the next time is:
Wrong type argument: commandp, (find-file "~/.emacs.d/init.el")
I also tried to put it into an own func, mimicking a working hotkey (for deft (global-set-key [f8] 'deft)
):
(defun sz-init-el ()
(interactive)
(find-file "~/.emacs.d/init.el"))
(global-set-key [f7] 'sz-init-el)
That worked. So I tried adding (interactive)
to my first trial:
(global-set-key [f7] '((interactive) (find-file "~/.emacs.d/init.el")))
But that would not work (again: Wrong type argument: commandp, ...
).
So, is there a way to set a global key binding without defining a function/command first? Or do I have to go via the defun
detour?
Thank you for your help and answers!