mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-04 19:10:37 -08:00
bind-keys-form: new keyword :repeat-map, for defining repeat maps
use-package-normalize/:bind: allow keyword :repeat-map. bind-keys-form: Add keyword :repeat-map. Specifying a symbol as the repeat-map defines a keymap with that name (and with the docstring `repeat-doc', if specified). Symbols for functions bound to keys under the scope of :repeat-map have their 'repeat-map property set to this map. Update docstring (and that of `bind-keys') to reflect changes. Rename `doc' to `prefix-doc' for clarity and consistency with 'repeat-doc'.
This commit is contained in:
parent
ffa5f0397a
commit
2203246454
2 changed files with 36 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ deferred until the prefix key sequence is pressed."
|
|||
;; :prefix-docstring STRING
|
||||
;; :prefix-map SYMBOL
|
||||
;; :prefix STRING
|
||||
;; :repeat-docstring STRING
|
||||
;; :repeat-map SYMBOL
|
||||
;; :filter SEXP
|
||||
;; :menu-name STRING
|
||||
;; :package SYMBOL
|
||||
|
|
@ -93,6 +95,8 @@ deferred until the prefix key sequence is pressed."
|
|||
(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)))
|
||||
(and (eq x :repeat-docstring) (stringp (cadr arg)))
|
||||
(eq x :filter)
|
||||
(and (eq x :menu-name) (stringp (cadr arg)))
|
||||
(and (eq x :package) (symbolp (cadr arg))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue