1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-25 07:28:20 +00:00

Prefer defvar-keymap in several cases

* lisp/calc/calc-embed.el (calc-override-minor-modes-map):
* lisp/calc/calc-yank.el (calc-edit-mode-map):
* lisp/calc/calc.el (calc-trail-mode-map):
* lisp/cedet/semantic/mru-bookmark.el (semantic-mru-bookmark-mode-map):
* lisp/cedet/semantic/util-modes.el (semantic-highlight-edits-mode-map)
(semantic-show-unmatched-syntax-mode-map)
(semantic-show-parser-state-mode-map)
(semantic-stickyfunc-mode-map, semantic-highlight-func-mode-map):
* lisp/cedet/srecode/srt-mode.el (srecode-template-mode-map):
* lisp/gnus/gnus-art.el (gnus-prev-page-map, gnus-next-page-map):
* lisp/gnus/gnus-search.el (gnus-search-minibuffer-map):
* lisp/gnus/score-mode.el (gnus-score-mode-map):
* lisp/gnus/smime.el (smime-mode-map):
* lisp/indent.el (edit-tab-stops-map):
* lisp/isearch.el (minibuffer-local-isearch-map):
* lisp/printing.el (pr-interface-map):
* lisp/progmodes/prog-mode.el (prog-mode-map):
* lisp/progmodes/subword.el (subword-mode-map):
* lisp/reveal.el (reveal-mode-map):
* lisp/strokes.el (strokes-mode-map):
* lisp/textmodes/flyspell.el (flyspell-mouse-map):
* lisp/textmodes/less-css-mode.el (less-css-mode-map):
* lisp/textmodes/remember.el (remember-mode-map)
(remember-notes-mode-map):
* lisp/wid-browse.el (widget-browse-mode-map):
* lisp/wid-edit.el (widget-key-sequence-map): Prefer defvar-keymap in
some easy-to-convert cases.
This commit is contained in:
Stefan Kangas 2022-09-13 15:05:28 +02:00
parent 280b40cd8a
commit aac4965702
22 changed files with 102 additions and 158 deletions

View File

@ -207,9 +207,8 @@
;; The following is to take care of any minor modes which override
;; a Calc command.
(defvar calc-override-minor-modes-map
(make-sparse-keymap)
"A list of keybindings that might be overwritten by minor modes.")
(defvar-keymap calc-override-minor-modes-map
:doc "A list of keybindings that might be overwritten by minor modes.")
;; Add any keys that might be overwritten here.
(define-key calc-override-minor-modes-map "`" 'calc-edit)

View File

@ -668,13 +668,11 @@ Interactively, reads the register using `register-read-with-preview'."
(backward-char 1)
(calc-set-command-flag 'do-edit))
(defvar calc-edit-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\n" #'calc-edit-finish)
(define-key map "\r" #'calc-edit-return)
(define-key map "\C-c\C-c" #'calc-edit-finish)
map)
"Keymap for use by the `calc-edit' command.")
(defvar-keymap calc-edit-mode-map
:doc "Keymap for use by the `calc-edit' command."
"C-j" #'calc-edit-finish
"RET" #'calc-edit-return
"C-c C-c" #'calc-edit-finish)
(defvar calc-original-buffer nil)
(defvar calc-return-buffer nil)

View File

@ -1373,10 +1373,8 @@ Notations: 3.14e6 3.14 * 10^6
(calc-check-defines))
(setplist 'calc-define nil)))))
(defvar calc-trail-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map calc-mode-map)
map))
(defvar-keymap calc-trail-mode-map
:parent calc-mode-map)
(defun calc--header-line (long short width &optional fudge)
"Return a Calc header line appropriate for the buffer WIDTH.

View File

@ -264,11 +264,9 @@ been edited, and you can re-visit them with \\[semantic-mrub-switch-tags]."
:group 'semantic
:type 'hook)
(defvar semantic-mru-bookmark-mode-map
(let ((km (make-sparse-keymap)))
(define-key km "\C-xB" #'semantic-mrub-switch-tags)
km)
"Keymap for mru-bookmark minor mode.")
(defvar-keymap semantic-mru-bookmark-mode-map
:doc "Keymap for mru-bookmark minor mode."
"C-x B" #'semantic-mrub-switch-tags)
(define-minor-mode semantic-mru-bookmark-mode
"Minor mode for tracking tag-based bookmarks automatically.

View File

@ -196,10 +196,8 @@ Argument OVERLAY is the overlay created to mark the change.
This function will set the face property on this overlay."
(overlay-put overlay 'face 'semantic-highlight-edits-face))
(defvar semantic-highlight-edits-mode-map
(let ((km (make-sparse-keymap)))
km)
"Keymap for highlight-edits minor mode.")
(defvar-keymap semantic-highlight-edits-mode-map
:doc "Keymap for highlight-edits minor mode.")
;;;###autoload
(define-minor-mode semantic-highlight-edits-mode
@ -343,11 +341,9 @@ Do not search past BOUND if non-nil."
(setq ol (cdr ol))))))
ol)))
(defvar semantic-show-unmatched-syntax-mode-map
(let ((km (make-sparse-keymap)))
(define-key km "\C-c,`" #'semantic-show-unmatched-syntax-next)
km)
"Keymap for command `semantic-show-unmatched-syntax-mode'.")
(defvar-keymap semantic-show-unmatched-syntax-mode-map
:doc "Keymap for command `semantic-show-unmatched-syntax-mode'."
"C-c , `" #'semantic-show-unmatched-syntax-next)
;;;###autoload
(define-minor-mode semantic-show-unmatched-syntax-mode
@ -417,10 +413,8 @@ non-nil if the minor mode is enabled.
:group 'semantic
:type 'hook)
(defvar semantic-show-parser-state-mode-map
(let ((km (make-sparse-keymap)))
km)
"Keymap for show-parser-state minor mode.")
(defvar-keymap semantic-show-parser-state-mode-map
:doc "Keymap for show-parser-state minor mode.")
;;;###autoload
(define-minor-mode semantic-show-parser-state-mode
@ -553,11 +547,9 @@ to indicate a parse in progress."
:group 'semantic
:type 'hook)
(defvar semantic-stickyfunc-mode-map
(let ((km (make-sparse-keymap)))
(define-key km [ header-line down-mouse-1 ] #'semantic-stickyfunc-menu)
km)
"Keymap for stickyfunc minor mode.")
(defvar-keymap semantic-stickyfunc-mode-map
:doc "Keymap for stickyfunc minor mode."
"<header-line> <down-mouse-1>" #'semantic-stickyfunc-menu)
(defvar semantic-stickyfunc-popup-menu nil
"Menu used if the user clicks on the header line used by stickyfunc mode.")
@ -824,11 +816,9 @@ Argument EVENT describes the event that caused this function to be called."
:group 'semantic
:type 'hook)
(defvar semantic-highlight-func-mode-map
(let ((km (make-sparse-keymap)))
(define-key km [mouse-3] #'semantic-highlight-func-menu)
km)
"Keymap for highlight-func minor mode.")
(defvar-keymap semantic-highlight-func-mode-map
:doc "Keymap for highlight-func minor mode."
"<mouse-3>" #'semantic-highlight-func-menu)
(defvar semantic-highlight-func-popup-menu nil
"Menu used if the user clicks on the header line.

View File

@ -179,13 +179,11 @@ Don't scan past LIMIT."
Once the escape_start, and escape_end sequences are known, then
we can tell font lock about them.")
(defvar srecode-template-mode-map
(let ((km (make-sparse-keymap)))
(define-key km "\C-c\C-c" #'srecode-compile-templates)
(define-key km "\C-c\C-m" #'srecode-macro-help)
(define-key km "/" #'srecode-self-insert-complete-end-macro)
km)
"Keymap used in srecode mode.")
(defvar-keymap srecode-template-mode-map
:doc "Keymap used in srecode mode."
"C-c C-c" #'srecode-compile-templates
"C-c C-m" #'srecode-macro-help
"/" #'srecode-self-insert-complete-end-macro)
;;;###autoload
(define-derived-mode srecode-template-mode fundamental-mode "SRecode"

View File

@ -8550,17 +8550,13 @@ url is put as the `gnus-button-url' overlay property on the button."
(defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
(defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
(defvar gnus-prev-page-map
(let ((map (make-sparse-keymap)))
(define-key map [mouse-2] #'gnus-button-prev-page)
(define-key map "\r" #'gnus-button-prev-page)
map))
(defvar-keymap gnus-prev-page-map
"<mouse-2>" #'gnus-button-prev-page
"RET" #'gnus-button-prev-page)
(defvar gnus-next-page-map
(let ((map (make-sparse-keymap)))
(define-key map [mouse-2] #'gnus-button-next-page)
(define-key map "\r" #'gnus-button-next-page)
map))
(defvar-keymap gnus-next-page-map
"<mouse-2>" #'gnus-button-next-page
"RET" #'gnus-button-next-page)
(defun gnus-insert-prev-page-button ()
(let ((b (point)) e

View File

@ -2247,11 +2247,9 @@ article came from is also searched."
(forward-line)))))
groups))
(defvar gnus-search-minibuffer-map
(let ((km (make-sparse-keymap)))
(set-keymap-parent km minibuffer-local-map)
(define-key km (kbd "TAB") #'completion-at-point)
km))
(defvar-keymap gnus-search-minibuffer-map
:parent minibuffer-local-map
"TAB" #'completion-at-point)
(defun gnus-search--complete-key-data ()
"Potentially return completion data for a search key or value."

View File

@ -45,13 +45,11 @@
(defvar gnus-score-edit-exit-function nil
"Function run on exit from the score buffer.")
(defvar gnus-score-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map emacs-lisp-mode-map)
(define-key map "\C-c\C-c" 'gnus-score-edit-exit)
(define-key map "\C-c\C-d" 'gnus-score-edit-insert-date)
(define-key map "\C-c\C-p" 'gnus-score-pretty-print)
map))
(defvar-keymap gnus-score-mode-map
:parent emacs-lisp-mode-map
"C-c C-c" #'gnus-score-edit-exit
"C-c C-d" #'gnus-score-edit-insert-date
"C-c C-p" #'gnus-score-pretty-print)
(defvar score-mode-syntax-table
(let ((table (copy-syntax-table lisp-mode-syntax-table)))

View File

@ -614,12 +614,10 @@ A string or a list of strings is returned."
(defvar smime-buffer "*SMIME*")
(defvar smime-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map)
(define-key map "q" 'smime-exit)
(define-key map "f" 'smime-certificate-info)
map))
(defvar-keymap smime-mode-map
:suppress t
"q" #'smime-exit
"f" #'smime-certificate-info)
(autoload 'gnus-completing-read "gnus-util")

View File

@ -695,12 +695,10 @@ A value of nil means a tab stop every `tab-width' columns."
:safe 'listp
:type '(repeat integer))
(defvar edit-tab-stops-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-x\C-s" 'edit-tab-stops-note-changes)
(define-key map "\C-c\C-c" 'edit-tab-stops-note-changes)
map)
"Keymap used in `edit-tab-stops'.")
(defvar-keymap edit-tab-stops-map
:doc "Keymap used in `edit-tab-stops'."
"C-x C-s" #'edit-tab-stops-note-changes
"C-c C-c" #'edit-tab-stops-note-changes)
(defvar edit-tab-stops-buffer nil
"Buffer whose tab stops are being edited.

View File

@ -832,17 +832,15 @@ This is like `describe-bindings', but displays only Isearch keys."
:image '(isearch-tool-bar-image "left-arrow")))
map))
(defvar minibuffer-local-isearch-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map minibuffer-local-map)
(define-key map "\r" 'exit-minibuffer)
(define-key map "\M-\t" 'isearch-complete-edit)
(define-key map "\C-s" 'isearch-forward-exit-minibuffer)
(define-key map "\C-r" 'isearch-reverse-exit-minibuffer)
(define-key map "\C-f" 'isearch-yank-char-in-minibuffer)
(define-key map [right] 'isearch-yank-char-in-minibuffer)
map)
"Keymap for editing Isearch strings in the minibuffer.")
(defvar-keymap minibuffer-local-isearch-map
:doc "Keymap for editing Isearch strings in the minibuffer."
:parent minibuffer-local-map
"RET" #'exit-minibuffer
"M-TAB" #'isearch-complete-edit
"C-s" #'isearch-forward-exit-minibuffer
"C-r" #'isearch-reverse-exit-minibuffer
"C-f" #'isearch-yank-char-in-minibuffer
"<right>" #'isearch-yank-char-in-minibuffer)
;; Internal variables declared globally for byte-compiler.
;; These are all set with setq while isearching

View File

@ -5546,13 +5546,11 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
(defvar pr-i-ps-send 'printer)
(defvar pr-interface-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map widget-keymap)
(define-key map "q" 'pr-interface-quit)
(define-key map "?" 'pr-interface-help)
map)
"Keymap for `pr-interface'.")
(defvar-keymap pr-interface-map
:doc "Keymap for `pr-interface'."
:parent widget-keymap
"q" #'pr-interface-quit
"?" #'pr-interface-help)
(defmacro pr-interface-save (&rest body)
`(with-current-buffer pr-i-buffer

View File

@ -100,11 +100,9 @@
menu)
(defvar prog-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [?\C-\M-q] 'prog-indent-sexp)
map)
"Keymap used for programming modes.")
(defvar-keymap prog-mode-map
:doc "Keymap used for programming modes."
"C-M-q" #'prog-indent-sexp)
(defvar prog-indentation-context nil
"When non-nil, provides context for indenting embedded code chunks.

View File

@ -79,12 +79,11 @@
"\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)\\|\\W\\w+\\)"
"Regexp used by `subword-backward-internal'.")
(defvar subword-mode-map
(defvar-keymap subword-mode-map
;; We originally remapped motion keys here, but now use Emacs core
;; hooks. Leave this keymap around so that user additions to it
;; keep working.
(make-sparse-keymap)
"Keymap used in `subword-mode' minor mode.")
:doc "Keymap used in `subword-mode' minor mode.")
;;;###autoload
(define-obsolete-function-alias

View File

@ -210,13 +210,11 @@ that text."
(let ((reveal-auto-hide t))
(reveal-post-command)))
(defvar reveal-mode-map
(let ((map (make-sparse-keymap)))
;; Override the default move-beginning-of-line and move-end-of-line
;; which skips valuable invisible text.
(define-key map [remap move-beginning-of-line] 'beginning-of-line)
(define-key map [remap move-end-of-line] 'end-of-line)
map))
(defvar-keymap reveal-mode-map
;; Override the default move-beginning-of-line and move-end-of-line
;; which skips valuable invisible text.
"<remap> <move-beginning-of-line>" #'beginning-of-line
"<remap> <move-end-of-line>" #'end-of-line)
;;;###autoload
(define-minor-mode reveal-mode

View File

@ -1359,11 +1359,9 @@ If STROKES-MAP is not given, `strokes-global-map' will be used instead."
"Return t if STROKE1's command name precedes STROKE2's in lexicographic order."
(string-lessp (cdr stroke1) (cdr stroke2)))
(defvar strokes-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [(shift down-mouse-2)] #'strokes-do-stroke)
(define-key map [(meta down-mouse-2)] #'strokes-do-complex-stroke)
map))
(defvar-keymap strokes-mode-map
"S-<down-mouse-2>" #'strokes-do-stroke
"M-<down-mouse-2>" #'strokes-do-complex-stroke)
;;;###autoload
(define-minor-mode strokes-mode

View File

@ -425,11 +425,9 @@ like <img alt=\"Some thing.\">."
;;*---------------------------------------------------------------------*/
;;* The minor mode declaration. */
;;*---------------------------------------------------------------------*/
(defvar flyspell-mouse-map
(let ((map (make-sparse-keymap)))
(define-key map [mouse-2] 'flyspell-correct-word)
map)
"Keymap for Flyspell to put on erroneous words.")
(defvar-keymap flyspell-mouse-map
:doc "Keymap for Flyspell to put on erroneous words."
"<mouse-2>" #'flyspell-correct-word)
(defvar flyspell-mode-map
(let ((map (make-sparse-keymap)))

View File

@ -209,10 +209,8 @@ directory by default."
(modify-syntax-entry ?. "'" st)
st))
(defvar less-css-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-c" #'less-css-compile)
map))
(defvar-keymap less-css-mode-map
"C-c C-c" #'less-css-compile)
;;;###autoload (add-to-list 'auto-mode-alist '("\\.less\\'" . less-css-mode))
;;;###autoload

View File

@ -548,13 +548,11 @@ If this is nil, then `diary-file' will be used instead."
;;; Internal Functions:
(defvar remember-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-x\C-s" #'remember-finalize)
(define-key map "\C-c\C-c" #'remember-finalize)
(define-key map "\C-c\C-k" #'remember-destroy)
map)
"Keymap used in `remember-mode'.")
(defvar-keymap remember-mode-map
:doc "Keymap used in `remember-mode'."
"C-x C-s" #'remember-finalize
"C-c C-c" #'remember-finalize
"C-c C-k" #'remember-destroy)
(define-derived-mode remember-mode text-mode "Remember"
"Major mode for output from \\[remember].
@ -596,11 +594,9 @@ If this is nil, use `initial-major-mode'."
(defvar remember-notes-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-c" #'remember-notes-save-and-bury-buffer)
map)
"Keymap used in `remember-notes-mode'.")
(defvar-keymap remember-notes-mode-map
:doc "Keymap used in `remember-notes-mode'."
"C-c C-c" #'remember-notes-save-and-bury-buffer)
(define-minor-mode remember-notes-mode
"Minor mode for the `remember-notes' buffer.

View File

@ -35,12 +35,10 @@
;;; The Mode.
(defvar widget-browse-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map widget-keymap)
(define-key map "q" #'bury-buffer)
map)
"Keymap for `widget-browse-mode'.")
(defvar-keymap widget-browse-mode-map
:doc "Keymap for `widget-browse-mode'."
:parent widget-keymap
"q" #'bury-buffer)
(easy-menu-define widget-browse-mode-customize-menu
widget-browse-mode-map
@ -245,11 +243,9 @@ VALUE is assumed to be a list of widgets."
;;; Widget Minor Mode.
(defvar widget-minor-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map widget-keymap)
map)
"Keymap used in Widget Minor Mode.")
(defvar-keymap widget-minor-mode-map
:doc "Keymap used in Widget Minor Mode."
:parent widget-keymap)
;;;###autoload
(define-minor-mode widget-minor-mode

View File

@ -3452,11 +3452,9 @@ It reads a directory name from an editable text field."
(defvar widget-key-sequence-default-value [ignore]
"Default value for an empty key sequence.")
(defvar widget-key-sequence-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map widget-field-keymap)
(define-key map [(control ?q)] 'widget-key-sequence-read-event)
map))
(defvar-keymap widget-key-sequence-map
:parent widget-field-keymap
"C-q" #'widget-key-sequence-read-event)
(define-widget 'key-sequence 'restricted-sexp
"A key sequence. This is obsolete; use the `key' type instead."