I want to bind f5
to launch pdb, but the minibuffer always says <f5>
is undefined.
(use-package python-mode
:bind (:map python-mode-map
("<[f5]>" . realgud:pdb))
:config
(load-library 'realgud))
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityI want to bind f5
to launch pdb, but the minibuffer always says <f5>
is undefined.
(use-package python-mode
:bind (:map python-mode-map
("<[f5]>" . realgud:pdb))
:config
(load-library 'realgud))
Try this:
(use-package python-mode
:bind (:map python-mode-map
([f5] . realgud:pdb)))
I can't see any reason why this would not work, but I should note that it's derived from my specific usage, which is slightly different.
I collect all my F-key bindings in an alist, directly calling bind-key
on the car
and cdr
of each element. bind-key
is what a :bind
stanza in a use-package
declaration expands to.
(defun ph/map-keys (key-mappings)
"Bind keys using alist KEY-MAPPINGS."
(dolist (key-mapping key-mappings)
(let ((key-chord (car key-mapping)) (command (cdr key-mapping)))
(when (and key-chord command (commandp command))
(bind-key key-chord command)))))
The simple vector form [f5]
works there for plain F-key bindings like ([f5] . my-command)
(as suggested by @NickD in a comment above). Modifiers need slightly more complex syntax: ([(control f5)] . my-command)
.
(kbd "<f5>")
?bind-keys
function, so that doesn't work.[f5]
work? In case, it's not clear, I know nothing aboutuse-package
, so you might want to ignore me and wait for somebody who knows something about it.(:map...)
sexp need to be quoted? Or more likely, does the cons("<[f5]>" . realgud:pdb)
need to be quoted? The question you cited shows no quotation, but it also doesn't show that you can use a:map
sexp. [IMHO it's too bad that things likeuse-package
(apparently) introduce another syntax for key binding. The existing syntax is already confusing enough.)]