]> git.eshelyaron.com Git - emacs.git/commitdiff
Prefer defvar-keymap in vc/*.el
authorStefan Kangas <stefan@marxist.se>
Wed, 10 Aug 2022 09:53:27 +0000 (11:53 +0200)
committerStefan Kangas <stefan@marxist.se>
Wed, 10 Aug 2022 09:53:27 +0000 (11:53 +0200)
* lisp/vc/add-log.el (change-log-mode-map):
* lisp/vc/ediff-mult.el (ediff-dir-diffs-buffer-map):
* lisp/vc/vc-annotate.el (vc-annotate-mode-map):
* lisp/vc/vc-bzr.el (vc-bzr-shelve-map):
* lisp/vc/vc-dir.el (vc-dir-status-mouse-map)
(vc-dir-filename-mouse-map):
* lisp/vc/vc-git.el (vc-git-stash-shared-map, vc-git-stash-map)
(vc-git-stash-button-map, vc-git-log-edit-mode-map):
* lisp/vc/vc-hg.el (vc-hg-log-edit-mode-map)
(vc-hg-extra-menu-map):
* lisp/vc/vc-hooks.el (vc-prefix-map): Prefer defvar-keymap.

lisp/vc/add-log.el
lisp/vc/ediff-mult.el
lisp/vc/vc-annotate.el
lisp/vc/vc-bzr.el
lisp/vc/vc-dir.el
lisp/vc/vc-git.el
lisp/vc/vc-hg.el
lisp/vc/vc-hooks.el

index e02d84f1f56aca109531ce3b51c6041bff47b0d4..d710578ffffddd9e81ee2c0decde613de6c4af09 100644 (file)
@@ -568,14 +568,12 @@ Compatibility function for \\[next-error] invocations."
        ;; Select window displaying source file.
        (select-window change-log-find-window)))))
 
-(defvar change-log-mode-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map [?\C-c ?\C-p] #'add-log-edit-prev-comment)
-    (define-key map [?\C-c ?\C-n] #'add-log-edit-next-comment)
-    (define-key map [?\C-c ?\C-f] #'change-log-find-file)
-    (define-key map [?\C-c ?\C-c] #'change-log-goto-source)
-    map)
-  "Keymap for Change Log major mode.")
+(defvar-keymap change-log-mode-map
+  :doc "Keymap for Change Log major mode."
+  "C-c C-p" #'add-log-edit-prev-comment
+  "C-c C-n" #'add-log-edit-next-comment
+  "C-c C-f" #'change-log-find-file
+  "C-c C-c" #'change-log-goto-source)
 
 (easy-menu-define change-log-mode-menu change-log-mode-map
   "Menu for Change Log major mode."
index 7e15060f8c47b943219b421fc1124ddc45047d87..52e356d8e9b2b5f09054fe1f056864efdf7bb0d7 100644 (file)
@@ -144,20 +144,18 @@ Useful commands (type ? to hide them and free up screen):
 
 (ediff-defvar-local ediff-meta-buffer-map nil
   "The keymap for the meta buffer.")
-(defvar ediff-dir-diffs-buffer-map
-  (let ((map (make-sparse-keymap)))
-    (suppress-keymap map)
-    (define-key map "q" #'ediff-bury-dir-diffs-buffer)
-    (define-key map " " #'next-line)
-    (define-key map "n" #'next-line)
-    (define-key map "\C-?" #'previous-line)
-    (define-key map "p" #'previous-line)
-    (define-key map "C" #'ediff-dir-diff-copy-file)
-    (define-key map  [mouse-2] #'ediff-dir-diff-copy-file)
-    (define-key map [delete] #'previous-line)
-    (define-key map [backspace] #'previous-line)
-    map)
-  "Keymap for buffer showing differences between directories.")
+(defvar-keymap ediff-dir-diffs-buffer-map
+  :doc "Keymap for buffer showing differences between directories."
+  :suppress t
+  "q"           #'ediff-bury-dir-diffs-buffer
+  "SPC"         #'next-line
+  "n"           #'next-line
+  "DEL"         #'previous-line
+  "p"           #'previous-line
+  "C"           #'ediff-dir-diff-copy-file
+  "<mouse-2>"   #'ediff-dir-diff-copy-file
+  "<delete>"    #'previous-line
+  "<backspace>" #'previous-line)
 
 ;; Variable specifying the action to take when the use invokes ediff in the
 ;; meta buffer.  This is usually ediff-registry-action or ediff-filegroup-action
index 1f19c4cfe266f0eb3c275fb0c9b13af3dff4e5a3..a15cf417de39b0c90d1cc2f1f8689cf01f2cf675 100644 (file)
@@ -162,22 +162,20 @@ List of factors, used to expand/compress the time scale.  See `vc-annotate'."
   :type '(repeat number)
   :group 'vc)
 
-(defvar vc-annotate-mode-map
-  (let ((m (make-sparse-keymap)))
-    (define-key m "a" #'vc-annotate-revision-previous-to-line)
-    (define-key m "d" #'vc-annotate-show-diff-revision-at-line)
-    (define-key m "=" #'vc-annotate-show-diff-revision-at-line)
-    (define-key m "D" #'vc-annotate-show-changeset-diff-revision-at-line)
-    (define-key m "f" #'vc-annotate-find-revision-at-line)
-    (define-key m "j" #'vc-annotate-revision-at-line)
-    (define-key m "l" #'vc-annotate-show-log-revision-at-line)
-    (define-key m "n" #'vc-annotate-next-revision)
-    (define-key m "p" #'vc-annotate-prev-revision)
-    (define-key m "w" #'vc-annotate-working-revision)
-    (define-key m "v" #'vc-annotate-toggle-annotation-visibility)
-    (define-key m "\C-m" #'vc-annotate-goto-line)
-    m)
-  "Local keymap used for VC-Annotate mode.")
+(defvar-keymap vc-annotate-mode-map
+  :doc "Local keymap used for VC-Annotate mode."
+  "a"   #'vc-annotate-revision-previous-to-line
+  "d"   #'vc-annotate-show-diff-revision-at-line
+  "="   #'vc-annotate-show-diff-revision-at-line
+  "D"   #'vc-annotate-show-changeset-diff-revision-at-line
+  "f"   #'vc-annotate-find-revision-at-line
+  "j"   #'vc-annotate-revision-at-line
+  "l"   #'vc-annotate-show-log-revision-at-line
+  "n"   #'vc-annotate-next-revision
+  "p"   #'vc-annotate-prev-revision
+  "w"   #'vc-annotate-working-revision
+  "v"   #'vc-annotate-toggle-annotation-visibility
+  "RET" #'vc-annotate-goto-line)
 
 ;;; Annotate functionality
 
index 072bd72b441eef4ebc8dda2935c417c91636bf4b..f6b17d4ce090161ded62f28ab38debd6e26a9bbb 100644 (file)
@@ -1008,19 +1008,17 @@ stream.  Standard error output is discarded."
                             ;; frob the results accordingly.
                             (file-relative-name dir (vc-bzr-root dir)))))
 
-(defvar vc-bzr-shelve-map
-  (let ((map (make-sparse-keymap)))
-    ;; Turn off vc-dir marking
-    (define-key map [mouse-2] #'ignore)
-
-    (define-key map [down-mouse-3] #'vc-bzr-shelve-menu)
-    (define-key map "\C-k" #'vc-bzr-shelve-delete-at-point)
-    (define-key map "=" #'vc-bzr-shelve-show-at-point)
-    (define-key map "\C-m" #'vc-bzr-shelve-show-at-point)
-    (define-key map "A" #'vc-bzr-shelve-apply-and-keep-at-point)
-    (define-key map "P" #'vc-bzr-shelve-apply-at-point)
-    (define-key map "S" #'vc-bzr-shelve-snapshot)
-    map))
+(defvar-keymap vc-bzr-shelve-map
+  ;; Turn off vc-dir marking
+  "<mouse-2>"      #'ignore
+
+  "<down-mouse-3>" #'vc-bzr-shelve-menu
+  "C-k"            #'vc-bzr-shelve-delete-at-point
+  "="              #'vc-bzr-shelve-show-at-point
+  "RET"            #'vc-bzr-shelve-show-at-point
+  "A"              #'vc-bzr-shelve-apply-and-keep-at-point
+  "P"              #'vc-bzr-shelve-apply-at-point
+  "S"              #'vc-bzr-shelve-snapshot)
 
 (defvar vc-bzr-shelve-menu-map
   (let ((map (make-sparse-keymap "Bzr Shelve")))
index 9335da10065cb2b9cd261e06a6cfaf10755aa231..068a66b25b8afd6854f77fef10c3d2f7a38f0d32 100644 (file)
@@ -1467,17 +1467,13 @@ These are the commands available for use in the file status buffer:
    (propertize "Please add backend specific headers here.  It's easy!"
               'face 'vc-dir-status-warning)))
 
-(defvar vc-dir-status-mouse-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map [mouse-2] #'vc-dir-toggle-mark)
-    map)
-  "Local keymap for toggling mark.")
+(defvar-keymap vc-dir-status-mouse-map
+  :doc "Local keymap for toggling mark."
+  "<mouse-2>" #'vc-dir-toggle-mark)
 
-(defvar vc-dir-filename-mouse-map
-   (let ((map (make-sparse-keymap)))
-     (define-key map [mouse-2] #'vc-dir-find-file-other-window)
-    map)
-  "Local keymap for visiting a file.")
+(defvar-keymap vc-dir-filename-mouse-map
+  :doc "Local keymap for visiting a file."
+  "<mouse-2>" #'vc-dir-find-file-other-window)
 
 (defun vc-default-dir-printer (_backend fileentry)
   "Pretty print FILEENTRY."
index 8937454d111bcb09c0b3a2481803125e57622925..46a486a46c3f763f1400b174f6f5cf08a865119d 100644 (file)
@@ -664,32 +664,26 @@ or an empty string if none."
                                  :files files
                                  :update-function update-function)))
 
-(defvar vc-git-stash-shared-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map "S" #'vc-git-stash-snapshot)
-    (define-key map "C" #'vc-git-stash)
-    map))
-
-(defvar vc-git-stash-map
-  (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map vc-git-stash-shared-map)
-    ;; Turn off vc-dir marking
-    (define-key map [mouse-2] #'ignore)
-
-    (define-key map [down-mouse-3] #'vc-git-stash-menu)
-    (define-key map "\C-k" #'vc-git-stash-delete-at-point)
-    (define-key map "=" #'vc-git-stash-show-at-point)
-    (define-key map "\C-m" #'vc-git-stash-show-at-point)
-    (define-key map "A" #'vc-git-stash-apply-at-point)
-    (define-key map "P" #'vc-git-stash-pop-at-point)
-    map))
-
-(defvar vc-git-stash-button-map
-  (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map vc-git-stash-shared-map)
-    (define-key map [mouse-2] #'push-button)
-    (define-key map "\C-m" #'push-button)
-    map))
+(defvar-keymap vc-git-stash-shared-map
+  "S" #'vc-git-stash-snapshot
+  "C" #'vc-git-stash)
+
+(defvar-keymap vc-git-stash-map
+  :parent vc-git-stash-shared-map
+  ;; Turn off vc-dir marking
+  "<mouse-2>"      #'ignore
+
+  "<down-mouse-3>" #'vc-git-stash-menu
+  "C-k"            #'vc-git-stash-delete-at-point
+  "="              #'vc-git-stash-show-at-point
+  "RET"            #'vc-git-stash-show-at-point
+  "A"              #'vc-git-stash-apply-at-point
+  "P"              #'vc-git-stash-pop-at-point)
+
+(defvar-keymap vc-git-stash-button-map
+  :parent vc-git-stash-shared-map
+  "<mouse-2>" #'push-button
+  "RET"     #'push-button)
 
 (defconst vc-git-stash-shared-help
   "\\<vc-git-stash-shared-map>\\[vc-git-stash]: Create named stash\n\\[vc-git-stash-snapshot]: Snapshot stash")
@@ -910,12 +904,11 @@ If toggling on, also insert its message into the buffer."
         standard-output 1 nil
         "log" "--max-count=1" "--pretty=format:%B" "HEAD")))))
 
-(defvar vc-git-log-edit-mode-map
-  (let ((map (make-sparse-keymap "Git-Log-Edit")))
-    (define-key map "\C-c\C-s" #'vc-git-log-edit-toggle-signoff)
-    (define-key map "\C-c\C-n" #'vc-git-log-edit-toggle-no-verify)
-    (define-key map "\C-c\C-e" #'vc-git-log-edit-toggle-amend)
-    map))
+(defvar-keymap vc-git-log-edit-mode-map
+  :name "Git-Log-Edit"
+  "C-c C-s" #'vc-git-log-edit-toggle-signoff
+  "C-c C-n" #'vc-git-log-edit-toggle-no-verify
+  "C-c C-e" #'vc-git-log-edit-toggle-amend)
 
 (define-derived-mode vc-git-log-edit-mode log-edit-mode "Log-Edit/git"
   "Major mode for editing Git log messages.
index 5fba2b3908abcdb3b10e0a906a3767fa55c464ff..61976288e351f1b9f9df27c03c64a73fb141b06b 100644 (file)
@@ -1177,10 +1177,9 @@ If toggling on, also insert its message into the buffer."
         standard-output 1 nil
         "log" "--limit=1" "--template" "{desc}")))))
 
-(defvar vc-hg-log-edit-mode-map
-  (let ((map (make-sparse-keymap "Hg-Log-Edit")))
-    (define-key map "\C-c\C-e" #'vc-hg-log-edit-toggle-amend)
-    map))
+(defvar-keymap vc-hg-log-edit-mode-map
+  :name "Hg-Log-Edit"
+  "C-c C-e" #'vc-hg-log-edit-toggle-amend)
 
 (define-derived-mode vc-hg-log-edit-mode log-edit-mode "Log-Edit/hg"
   "Major mode for editing Hg log messages.
@@ -1262,9 +1261,7 @@ REV is the revision to check out into WORKFILE."
 
 ;;; Hg specific functionality.
 
-(defvar vc-hg-extra-menu-map
-  (let ((map (make-sparse-keymap)))
-    map))
+(defvar-keymap vc-hg-extra-menu-map)
 
 (defun vc-hg-extra-menu () vc-hg-extra-menu-map)
 
index 405c9bc2ca46b9b4a2c324dc9029cc5b65ea142b..1f0eeb7e18a2dc60ffd7e6844def66d321a86436 100644 (file)
@@ -855,38 +855,37 @@ In the latter case, VC mode is deactivated for this buffer."
 ;; Autoloading works fine, but it prevents shortcuts from appearing
 ;; in the menu because they don't exist yet when the menu is built.
 ;; (autoload 'vc-prefix-map "vc" nil nil 'keymap)
-(defvar vc-prefix-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map "a" #'vc-update-change-log)
-    (with-suppressed-warnings ((obsolete vc-switch-backend))
-      (define-key map "b" #'vc-switch-backend))
-    (define-key map "d" #'vc-dir)
-    (define-key map "g" #'vc-annotate)
-    (define-key map "G" #'vc-ignore)
-    (define-key map "h" #'vc-region-history)
-    (define-key map "i" #'vc-register)
-    (define-key map "l" #'vc-print-log)
-    (define-key map "L" #'vc-print-root-log)
-    (define-key map "I" #'vc-log-incoming)
-    (define-key map "O" #'vc-log-outgoing)
-    (define-key map "ML" #'vc-log-mergebase)
-    (define-key map "MD" #'vc-diff-mergebase)
-    (define-key map "m" #'vc-merge)
-    (define-key map "r" #'vc-retrieve-tag)
-    (define-key map "s" #'vc-create-tag)
-    (define-key map "u" #'vc-revert)
-    (define-key map "v" #'vc-next-action)
-    (define-key map "+" #'vc-update)
-    ;; I'd prefer some kind of symmetry with vc-update:
-    (define-key map "P" #'vc-push)
-    (define-key map "=" #'vc-diff)
-    (define-key map "D" #'vc-root-diff)
-    (define-key map "~" #'vc-revision-other-window)
-    (define-key map "x" #'vc-delete-file)
-    map))
+(defvar-keymap vc-prefix-map
+  "a"   #'vc-update-change-log
+  "d"   #'vc-dir
+  "g"   #'vc-annotate
+  "G"   #'vc-ignore
+  "h"   #'vc-region-history
+  "i"   #'vc-register
+  "l"   #'vc-print-log
+  "L"   #'vc-print-root-log
+  "I"   #'vc-log-incoming
+  "O"   #'vc-log-outgoing
+  "M L" #'vc-log-mergebase
+  "M D" #'vc-diff-mergebase
+  "m"   #'vc-merge
+  "r"   #'vc-retrieve-tag
+  "s"   #'vc-create-tag
+  "u"   #'vc-revert
+  "v"   #'vc-next-action
+  "+"   #'vc-update
+  ;; I'd prefer some kind of symmetry with vc-update:
+  "P"   #'vc-push
+  "="   #'vc-diff
+  "D"   #'vc-root-diff
+  "~"   #'vc-revision-other-window
+  "x"   #'vc-delete-file)
 (fset 'vc-prefix-map vc-prefix-map)
 (define-key ctl-x-map "v" 'vc-prefix-map)
 
+(with-suppressed-warnings ((obsolete vc-switch-backend))
+  (keymap-set vc-prefix-map "b" #'vc-switch-backend))
+
 (defvar vc-menu-map
   (let ((map (make-sparse-keymap "Version Control")))
     ;;(define-key map [show-files]