summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Heagren <hugo@heagren.com>2022-01-20 10:59:37 +0000
committerHugo Heagren <hugo@heagren.com>2022-01-28 22:37:37 +0000
commitc4bd2aa3b8094135c34c86893790f051cb5e1457 (patch)
tree2e87e971240373a60379285b9fb67fb66bc5334e
parent5ef327ce9fc1397cdbbde8936eca37ae6383d787 (diff)
downloademacs-c4bd2aa3b8.tar.gz
bind-key-form: allow :continue keyword inside repeat map
Purely syntactic sugar, using :continue is the same as not using any keyword inside :repeat-map at all. Amend end of function to pass repeat-map value onto next invocation in recursive uses. This allows for the same repeat map to be used for :exit and :continue.
-rw-r--r--lisp/use-package/bind-key.el18
-rw-r--r--lisp/use-package/use-package-bind-key.el3
2 files changed, 17 insertions, 4 deletions
diff --git a/lisp/use-package/bind-key.el b/lisp/use-package/bind-key.el
index a899aca0ffc..87a33e3d6ca 100644
--- a/lisp/use-package/bind-key.el
+++ b/lisp/use-package/bind-key.el
@@ -266,6 +266,10 @@ Accepts keyword arguments:
:exit BINDINGS - Within the scope of :repeat-map will bind the
key in the repeat map, but will not set the
'repeat-map property of the bound command.
+:continue BINDINGS - Within the scope of :repeat-map forces the
+ same behaviour as if no special keyword had
+ been used (that is, the command is bound, and
+ it's 'repeat-map property set)
:filter FORM - optional form to determine when bindings apply
The rest of the arguments are conses of keybinding string and a
@@ -301,6 +305,9 @@ function symbol (unquoted)."
override-global-map))))
(setq repeat-map (cadr args))
(setq map repeat-map))
+ ((eq :continue (car args))
+ (setq repeat-type :continue
+ arg-change-func 'cdr))
((eq :exit (car args))
(setq repeat-type :exit
arg-change-func 'cdr))
@@ -376,9 +383,10 @@ function symbol (unquoted)."
`((bind-key ,(car form) ,fun nil ,filter))))))
first))
(when next
- (bind-keys-form (if pkg
- (cons :package (cons pkg next))
- next) map)))))))
+ (bind-keys-form `(,@(when repeat-map `(:repeat-map ,repeat-map))
+ ,@(if pkg
+ (cons :package (cons pkg next))
+ next)) map)))))))
;;;###autoload
(defmacro bind-keys (&rest args)
@@ -401,6 +409,10 @@ Accepts keyword arguments:
:exit BINDINGS - Within the scope of :repeat-map will bind the
key in the repeat map, but will not set the
'repeat-map property of the bound command.
+:continue BINDINGS - Within the scope of :repeat-map forces the
+ same behaviour as if no special keyword had
+ been used (that is, the command is bound, and
+ it's 'repeat-map property set)
:filter FORM - optional form to determine when bindings apply
The rest of the arguments are conses of keybinding string and a
diff --git a/lisp/use-package/use-package-bind-key.el b/lisp/use-package/use-package-bind-key.el
index 73ea8ca83e0..9642f311750 100644
--- a/lisp/use-package/use-package-bind-key.el
+++ b/lisp/use-package/use-package-bind-key.el
@@ -91,12 +91,13 @@ deferred until the prefix key sequence is pressed."
;; :filter SEXP
;; :menu-name STRING
;; :package SYMBOL
- ;; :exit used within :repeat-map
+ ;; :continue and :exit are used within :repeat-map
((or (and (eq x :map) (symbolp (cadr arg)))
(and (eq x :prefix) (stringp (cadr arg)))
(and (eq x :prefix-map) (symbolp (cadr arg)))
(and (eq x :prefix-docstring) (stringp (cadr arg)))
(and (eq x :repeat-map) (symbolp (cadr arg)))
+ (eq x :continue)
(eq x :exit)
(and (eq x :repeat-docstring) (stringp (cadr arg)))
(eq x :filter)