mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
defvar-keymap: New ':prefix t' abbreviation
* lisp/keymap.el (defvar-keymap): New ':prefix t' abbreviation. * lisp/emacs-lisp/helper.el (Helper-help-map): * lisp/vc/pcvs.el (cvs-mode-diff-map): * lisp/vc/vc-hooks.el (vc-prefix-map): * lisp/vcursor.el (vcursor-map): Use it. * doc/lispref/keymaps.texi (Creating Keymaps): * etc/NEWS: Document it.
This commit is contained in:
parent
1df9cfdb13
commit
7f925b06ac
7 changed files with 56 additions and 20 deletions
|
|
@ -650,11 +650,9 @@ and @var{pairs} to @code{define-keymap}, and uses the result as the
|
||||||
default value for the variable. It signals an error if there are
|
default value for the variable. It signals an error if there are
|
||||||
duplicate key bindings in @var{pairs}.
|
duplicate key bindings in @var{pairs}.
|
||||||
|
|
||||||
@var{options} is like the keywords in @code{define-keymap}, but
|
@var{options} is mostly like the keywords in @code{define-keymap}.
|
||||||
there's an additional @code{:doc} keyword that provides the doc
|
There's an additional @code{:doc} keyword that provides the doc string
|
||||||
string for the defined variable.
|
for the defined variable. Here's an example:
|
||||||
|
|
||||||
Here's an example:
|
|
||||||
|
|
||||||
@lisp
|
@lisp
|
||||||
(defvar-keymap eww-textarea-map
|
(defvar-keymap eww-textarea-map
|
||||||
|
|
@ -664,6 +662,24 @@ Here's an example:
|
||||||
"TAB" #'shr-next-link)
|
"TAB" #'shr-next-link)
|
||||||
@end lisp
|
@end lisp
|
||||||
|
|
||||||
|
The @code{:prefix} keyword can take an additional value, @code{t}, which
|
||||||
|
is an abbreviation for using @var{name} as the value of that option.
|
||||||
|
I.e. instead of writing
|
||||||
|
|
||||||
|
@lisp
|
||||||
|
(defvar-keymap foo-map
|
||||||
|
:prefix 'foo-map
|
||||||
|
...)
|
||||||
|
@end lisp
|
||||||
|
|
||||||
|
you can write
|
||||||
|
|
||||||
|
@lisp
|
||||||
|
(defvar-keymap foo-map
|
||||||
|
:prefix t
|
||||||
|
...)
|
||||||
|
@end lisp
|
||||||
|
|
||||||
@kindex :repeat
|
@kindex :repeat
|
||||||
@kindex repeat-mode
|
@kindex repeat-mode
|
||||||
@cindex repeatable key bindings
|
@cindex repeatable key bindings
|
||||||
|
|
|
||||||
6
etc/NEWS
6
etc/NEWS
|
|
@ -3310,6 +3310,12 @@ a remote host. It must be used in conjunction with the function
|
||||||
The column number is no longer available; the line number will be
|
The column number is no longer available; the line number will be
|
||||||
removed in next Emacs release.
|
removed in next Emacs release.
|
||||||
|
|
||||||
|
+++
|
||||||
|
** defvar-keymap can now take a ':prefix t' option.
|
||||||
|
This is an abbreviation for using the name of the keymap as the prefix
|
||||||
|
command name. E.g. (defvar-keymap foo-map :prefix t) is equivalent to
|
||||||
|
(defvar-keymap foo-map :prefix 'foo-map).
|
||||||
|
|
||||||
|
|
||||||
* Changes in Emacs 31.1 on Non-Free Operating Systems
|
* Changes in Emacs 31.1 on Non-Free Operating Systems
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
|
|
||||||
(defvar-keymap Helper-help-map
|
(defvar-keymap Helper-help-map
|
||||||
|
:prefix t
|
||||||
"m" #'Helper-describe-mode
|
"m" #'Helper-describe-mode
|
||||||
"b" #'Helper-describe-bindings
|
"b" #'Helper-describe-bindings
|
||||||
"c" #'Helper-describe-key-briefly
|
"c" #'Helper-describe-key-briefly
|
||||||
|
|
@ -48,7 +49,6 @@
|
||||||
;;"v" #'Helper-describe-variable
|
;;"v" #'Helper-describe-variable
|
||||||
"?" #'Helper-help-options
|
"?" #'Helper-help-options
|
||||||
(help-key) #'Helper-help-options)
|
(help-key) #'Helper-help-options)
|
||||||
(fset 'Helper-help-map Helper-help-map)
|
|
||||||
|
|
||||||
(defun Helper-help-scroller ()
|
(defun Helper-help-scroller ()
|
||||||
(let ((blurb (or (and (boundp 'Helper-return-blurb)
|
(let ((blurb (or (and (boundp 'Helper-return-blurb)
|
||||||
|
|
|
||||||
|
|
@ -614,9 +614,11 @@ pairs. Available keywords are:
|
||||||
:name If non-nil, this should be a string to use as the menu for
|
:name If non-nil, this should be a string to use as the menu for
|
||||||
the keymap in case you use it as a menu with `x-popup-menu'.
|
the keymap in case you use it as a menu with `x-popup-menu'.
|
||||||
|
|
||||||
:prefix If non-nil, this should be a symbol to be used as a prefix
|
:prefix If non-nil, this should be a symbol to make into a prefix command
|
||||||
command (see `define-prefix-command'). If this is the case,
|
using the new keymap (see `define-prefix-command').
|
||||||
this symbol is returned instead of the map itself.
|
That is, store the keymap as the symbol's function definition.
|
||||||
|
In addition, when non-nil, return the symbol instead of the
|
||||||
|
new keymap.
|
||||||
|
|
||||||
KEY/DEFINITION pairs are as KEY and DEF in `keymap-set'. KEY can
|
KEY/DEFINITION pairs are as KEY and DEF in `keymap-set'. KEY can
|
||||||
also be the special symbol `:menu', in which case DEFINITION
|
also be the special symbol `:menu', in which case DEFINITION
|
||||||
|
|
@ -689,6 +691,9 @@ In addition to the keywords accepted by `define-keymap', this
|
||||||
macro also accepts a `:doc' keyword, which (if present) is used
|
macro also accepts a `:doc' keyword, which (if present) is used
|
||||||
as the variable documentation string.
|
as the variable documentation string.
|
||||||
|
|
||||||
|
The `:prefix' keyword can take an additional value, t, which is an
|
||||||
|
abbreviation for using VARIABLE-NAME as the prefix command name.
|
||||||
|
|
||||||
The `:repeat' keyword can also be specified; it controls the
|
The `:repeat' keyword can also be specified; it controls the
|
||||||
`repeat-mode' behavior of the bindings in the keymap. When it is
|
`repeat-mode' behavior of the bindings in the keymap. When it is
|
||||||
non-nil, all commands in the map will have the `repeat-map'
|
non-nil, all commands in the map will have the `repeat-map'
|
||||||
|
|
@ -734,10 +739,17 @@ in the echo area.
|
||||||
(unless defs
|
(unless defs
|
||||||
(error "Uneven number of keywords"))
|
(error "Uneven number of keywords"))
|
||||||
(cond
|
(cond
|
||||||
((eq keyword :doc) (setq doc (pop defs)))
|
((eq keyword :doc)
|
||||||
((eq keyword :repeat) (setq repeat (pop defs)))
|
(setq doc (pop defs)))
|
||||||
(t (push keyword opts)
|
((eq keyword :repeat)
|
||||||
(push (pop defs) opts)))))
|
(setq repeat (pop defs)))
|
||||||
|
((and (eq keyword :prefix) (eq (car defs) t))
|
||||||
|
(setq defs (cdr defs))
|
||||||
|
(push keyword opts)
|
||||||
|
(push `',variable-name opts))
|
||||||
|
(t
|
||||||
|
(push keyword opts)
|
||||||
|
(push (pop defs) opts)))))
|
||||||
(unless (zerop (% (length defs) 2))
|
(unless (zerop (% (length defs) 2))
|
||||||
(error "Uneven number of key/definition pairs: %s" defs))
|
(error "Uneven number of key/definition pairs: %s" defs))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,10 @@
|
||||||
|
|
||||||
(defvar-keymap cvs-mode-diff-map
|
(defvar-keymap cvs-mode-diff-map
|
||||||
:name "Diff"
|
:name "Diff"
|
||||||
|
;; This is necessary to allow correct handling of
|
||||||
|
;; \\[cvs-mode-diff-map] in substitute-command-keys.
|
||||||
|
:prefix t
|
||||||
|
|
||||||
"E" (cons "imerge" #'cvs-mode-imerge)
|
"E" (cons "imerge" #'cvs-mode-imerge)
|
||||||
"=" #'cvs-mode-diff
|
"=" #'cvs-mode-diff
|
||||||
"e" (cons "idiff" #'cvs-mode-idiff)
|
"e" (cons "idiff" #'cvs-mode-idiff)
|
||||||
|
|
@ -150,9 +154,6 @@
|
||||||
"r" (cons "repository" #'cvs-mode-diff-repository)
|
"r" (cons "repository" #'cvs-mode-diff-repository)
|
||||||
"y" (cons "yesterday" #'cvs-mode-diff-yesterday)
|
"y" (cons "yesterday" #'cvs-mode-diff-yesterday)
|
||||||
"v" (cons "vendor" #'cvs-mode-diff-vendor))
|
"v" (cons "vendor" #'cvs-mode-diff-vendor))
|
||||||
;; This is necessary to allow correct handling of \\[cvs-mode-diff-map]
|
|
||||||
;; in substitute-command-keys.
|
|
||||||
(fset 'cvs-mode-diff-map cvs-mode-diff-map)
|
|
||||||
|
|
||||||
(defvar-keymap cvs-mode-map
|
(defvar-keymap cvs-mode-map
|
||||||
:full t
|
:full t
|
||||||
|
|
|
||||||
|
|
@ -965,6 +965,7 @@ In the latter case, VC mode is deactivated for this buffer."
|
||||||
;; in the menu because they don't exist yet when the menu is built.
|
;; in the menu because they don't exist yet when the menu is built.
|
||||||
;; (autoload 'vc-prefix-map "vc" nil nil 'keymap)
|
;; (autoload 'vc-prefix-map "vc" nil nil 'keymap)
|
||||||
(defvar-keymap vc-prefix-map
|
(defvar-keymap vc-prefix-map
|
||||||
|
:prefix t
|
||||||
"a" #'vc-update-change-log
|
"a" #'vc-update-change-log
|
||||||
"b c" #'vc-create-branch
|
"b c" #'vc-create-branch
|
||||||
"b l" #'vc-print-branch-log
|
"b l" #'vc-print-branch-log
|
||||||
|
|
@ -1003,7 +1004,6 @@ In the latter case, VC mode is deactivated for this buffer."
|
||||||
"w R" #'vc-move-working-tree
|
"w R" #'vc-move-working-tree
|
||||||
"w a" #'vc-apply-to-other-working-tree
|
"w a" #'vc-apply-to-other-working-tree
|
||||||
"w A" #'vc-apply-root-to-other-working-tree)
|
"w A" #'vc-apply-root-to-other-working-tree)
|
||||||
(fset 'vc-prefix-map vc-prefix-map)
|
|
||||||
(define-key ctl-x-map "v" 'vc-prefix-map)
|
(define-key ctl-x-map "v" 'vc-prefix-map)
|
||||||
|
|
||||||
(defvar-keymap vc-incoming-prefix-map
|
(defvar-keymap vc-incoming-prefix-map
|
||||||
|
|
|
||||||
|
|
@ -467,6 +467,10 @@ scrolling set this. It is used by the `vcursor-auto-disable' code.")
|
||||||
|
|
||||||
(defvar-keymap vcursor-map
|
(defvar-keymap vcursor-map
|
||||||
:doc "Keymap for vcursor command."
|
:doc "Keymap for vcursor command."
|
||||||
|
;; This seems unused but was done previously (Emacs 24), so is kept
|
||||||
|
;; for now.
|
||||||
|
:prefix t
|
||||||
|
|
||||||
"t" #'vcursor-use-vcursor-map
|
"t" #'vcursor-use-vcursor-map
|
||||||
|
|
||||||
"C-p" #'vcursor-previous-line
|
"C-p" #'vcursor-previous-line
|
||||||
|
|
@ -495,9 +499,6 @@ scrolling set this. It is used by the `vcursor-auto-disable' code.")
|
||||||
"c" #'vcursor-compare-windows
|
"c" #'vcursor-compare-windows
|
||||||
"k" #'vcursor-execute-key
|
"k" #'vcursor-execute-key
|
||||||
"M-x" #'vcursor-execute-command)
|
"M-x" #'vcursor-execute-command)
|
||||||
;; This seems unused, but it was done as part of define-prefix-command,
|
|
||||||
;; so let's keep it for now.
|
|
||||||
(fset 'vcursor-map vcursor-map)
|
|
||||||
|
|
||||||
;; If vcursor-key-bindings is already set on loading, bind the keys now.
|
;; If vcursor-key-bindings is already set on loading, bind the keys now.
|
||||||
;; This hybrid way of doing it retains compatibility while allowing
|
;; This hybrid way of doing it retains compatibility while allowing
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue