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 community
(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
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).