]> git.eshelyaron.com Git - emacs.git/commitdiff
bind-key-form: allow :continue keyword inside repeat map
authorHugo Heagren <hugo@heagren.com>
Thu, 20 Jan 2022 10:59:37 +0000 (10:59 +0000)
committerHugo Heagren <hugo@heagren.com>
Fri, 28 Jan 2022 22:37:37 +0000 (22:37 +0000)
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.

lisp/use-package/bind-key.el
lisp/use-package/use-package-bind-key.el

index a899aca0ffcd1e8a445a016272ab12d13ec3151c..87a33e3d6ca8d43742f5394abb2d659388b8484f 100644 (file)
@@ -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
index 73ea8ca83e0d753dacd3b6daf16abe01e3e8ee6c..9642f311750df026a3f790a30eb09376a9aaf5c5 100644 (file)
@@ -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)