1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-24 13:32:41 -08:00

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.
This commit is contained in:
Hugo Heagren 2022-01-20 10:59:37 +00:00
parent 5ef327ce9f
commit c4bd2aa3b8
2 changed files with 17 additions and 4 deletions

View 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

View 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)