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.el36
1 files changed, 32 insertions, 4 deletions
diff --git a/lisp/use-package/bind-key.el b/lisp/use-package/bind-key.el
index 1d611c2933c..bb09a6935a8 100644
--- a/lisp/use-package/bind-key.el
+++ b/lisp/use-package/bind-key.el
@@ -257,14 +257,22 @@ Accepts keyword arguments:
for these bindings
:prefix-docstring STR - docstring for the prefix-map variable
:menu-name NAME - optional menu string for prefix map
+:repeat-docstring STR - docstring for the repeat-map variable
+:repeat-map MAP - name of the repeat map that should be created
+ for these bindings. If specified, the
+ 'repeat-map property of each command bound
+ (within the scope of the :repeat-map keyword)
+ is set to this map.
:filter FORM - optional form to determine when bindings apply
The rest of the arguments are conses of keybinding string and a
function symbol (unquoted)."
(let (map
- doc
+ prefix-doc
prefix-map
prefix
+ repeat-map
+ repeat-doc
filter
menu-name
pkg)
@@ -276,11 +284,18 @@ function symbol (unquoted)."
(not prefix-map))
(setq map (cadr args)))
((eq :prefix-docstring (car args))
- (setq doc (cadr args)))
+ (setq prefix-doc (cadr args)))
((and (eq :prefix-map (car args))
(not (memq map '(global-map
override-global-map))))
(setq prefix-map (cadr args)))
+ ((eq :repeat-docstring (car args))
+ (setq repeat-doc (cadr args)))
+ ((and (eq :repeat-map (car args))
+ (not (memq map '(global-map
+ override-global-map))))
+ (setq repeat-map (cadr args))
+ (setq map repeat-map))
((eq :prefix (car args))
(setq prefix (cadr args)))
((eq :filter (car args))
@@ -327,13 +342,16 @@ function symbol (unquoted)."
(append
(when prefix-map
`((defvar ,prefix-map)
- ,@(when doc `((put ',prefix-map 'variable-documentation ,doc)))
+ ,@(when prefix-doc `((put ',prefix-map 'variable-documentation ,prefix-doc)))
,@(if menu-name
`((define-prefix-command ',prefix-map nil ,menu-name))
`((define-prefix-command ',prefix-map)))
,@(if (and map (not (eq map 'global-map)))
(wrap map `((bind-key ,prefix ',prefix-map ,map ,filter)))
`((bind-key ,prefix ',prefix-map nil ,filter)))))
+ (when repeat-map
+ `((defvar ,repeat-map (make-sparse-keymap)
+ ,@(when repeat-doc `(,repeat-doc)))))
(wrap map
(cl-mapcan
(lambda (form)
@@ -341,7 +359,11 @@ function symbol (unquoted)."
(if prefix-map
`((bind-key ,(car form) ,fun ,prefix-map ,filter))
(if (and map (not (eq map 'global-map)))
- `((bind-key ,(car form) ,fun ,map ,filter))
+ ;; Only needed in this branch, since when
+ ;; repeat-map is non-nil, map is always
+ ;; non-nil
+ `(,@(when repeat-map `((put ,fun 'repeat-map ',repeat-map)))
+ (bind-key ,(car form) ,fun ,map ,filter))
`((bind-key ,(car form) ,fun nil ,filter))))))
first))
(when next
@@ -361,6 +383,12 @@ Accepts keyword arguments:
for these bindings
:prefix-docstring STR - docstring for the prefix-map variable
:menu-name NAME - optional menu string for prefix map
+:repeat-docstring STR - docstring for the repeat-map variable
+:repeat-map MAP - name of the repeat map that should be created
+ for these bindings. If specified, the
+ 'repeat-map property of each command bound
+ (within the scope of the :repeat-map keyword)
+ is set to this map.
:filter FORM - optional form to determine when bindings apply
The rest of the arguments are conses of keybinding string and a