summaryrefslogtreecommitdiff
path: root/lisp/use-package/bind-key.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/use-package/bind-key.el')
-rw-r--r--lisp/use-package/bind-key.el13
1 files changed, 8 insertions, 5 deletions
diff --git a/lisp/use-package/bind-key.el b/lisp/use-package/bind-key.el
index 01e1d4d73d9..fef23740c67 100644
--- a/lisp/use-package/bind-key.el
+++ b/lisp/use-package/bind-key.el
@@ -154,11 +154,13 @@ spelled-out keystrokes, e.g., \"C-c C-z\". See documentation of
COMMAND must be an interactive function or lambda form.
-KEYMAP, if present, should be a keymap and not a quoted symbol.
+KEYMAP, if present, should be a keymap variable or symbol.
For example:
(bind-key \"M-h\" #'some-interactive-function my-mode-map)
+ (bind-key \"M-h\" #'some-interactive-function 'my-mode-map)
+
If PREDICATE is non-nil, it is a form evaluated to determine when
a key should be bound. It must return non-nil in such cases.
Emacs can evaluate this form at any time that it does redisplay
@@ -171,10 +173,11 @@ can safely be called at any time."
`(let* ((,namevar ,key-name)
(,keyvar (if (vectorp ,namevar) ,namevar
(read-kbd-macro ,namevar)))
+ (kmap (if (and ,keymap (symbolp ,keymap)) (symbol-value ,keymap) ,keymap))
(,kdescvar (cons (if (stringp ,namevar) ,namevar
(key-description ,namevar))
- (quote ,keymap)))
- (,bindingvar (lookup-key (or ,keymap global-map) ,keyvar)))
+ (if (symbolp ,keymap) ,keymap (quote ,keymap))))
+ (,bindingvar (lookup-key (or kmap global-map) ,keyvar)))
(let ((entry (assoc ,kdescvar personal-keybindings))
(details (list ,command
(unless (numberp ,bindingvar)
@@ -183,11 +186,11 @@ can safely be called at any time."
(setcdr entry details)
(add-to-list 'personal-keybindings (cons ,kdescvar details))))
,(if predicate
- `(define-key (or ,keymap global-map) ,keyvar
+ `(define-key (or kmap global-map) ,keyvar
'(menu-item "" nil :filter (lambda (&optional _)
(when ,predicate
,command))))
- `(define-key (or ,keymap global-map) ,keyvar ,command)))))
+ `(define-key (or kmap global-map) ,keyvar ,command)))))
;;;###autoload
(defmacro unbind-key (key-name &optional keymap)