emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 9efa67f: Convert diff-mode.el from easy-mmode-defmap to define-ke


From: Lars Ingebrigtsen
Subject: master 9efa67f: Convert diff-mode.el from easy-mmode-defmap to define-keymap
Date: Sun, 17 Oct 2021 18:50:09 -0400 (EDT)

branch: master
commit 9efa67f764cc55ceaf846eccf61a6943975f0d6d
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Convert diff-mode.el from easy-mmode-defmap to define-keymap
    
    * lisp/vc/diff-mode.el (diff-mode-shared-map, diff-mode-map)
    (diff-minor-mode-map): Convert from easy-mmode-defmap to
    defvar-keymap.
---
 lisp/vc/diff-mode.el | 106 +++++++++++++++++++++++++--------------------------
 1 file changed, 52 insertions(+), 54 deletions(-)

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 057ffcd..297bf4a 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -162,57 +162,55 @@ and hunk-based syntax highlighting otherwise as a 
fallback."
 ;;;; keymap, menu, ...
 ;;;;
 
-(easy-mmode-defmap diff-mode-shared-map
-  '(("n" . diff-hunk-next)
-    ("N" . diff-file-next)
-    ("p" . diff-hunk-prev)
-    ("P" . diff-file-prev)
-    ("\t" . diff-hunk-next)
-    ([backtab] . diff-hunk-prev)
-    ("k" . diff-hunk-kill)
-    ("K" . diff-file-kill)
-    ("}" . diff-file-next)     ; From compilation-minor-mode.
-    ("{" . diff-file-prev)
-    ("\C-m" . diff-goto-source)
-    ([mouse-2] . diff-goto-source)
-    ("W" . widen)
-    ("o" . diff-goto-source)   ; other-window
-    ("A" . diff-ediff-patch)
-    ("r" . diff-restrict-view)
-    ("R" . diff-reverse-direction)
-    ([remap undo] . diff-undo))
-  "Basic keymap for `diff-mode', bound to various prefix keys."
-  :inherit special-mode-map)
-
-(easy-mmode-defmap diff-mode-map
-  `(("\e" . ,(let ((map (make-sparse-keymap)))
-               ;; We want to inherit most bindings from diff-mode-shared-map,
-               ;; but not all since they may hide useful M-<foo> global
-               ;; bindings when editing.
-               (set-keymap-parent map diff-mode-shared-map)
-               (dolist (key '("A" "r" "R" "g" "q" "W" "z"))
-                 (define-key map key nil))
-               map))
-    ;; From compilation-minor-mode.
-    ("\C-c\C-c" . diff-goto-source)
-    ;; By analogy with the global C-x 4 a binding.
-    ("\C-x4A" . diff-add-change-log-entries-other-window)
-    ;; Misc operations.
-    ("\C-c\C-a" . diff-apply-hunk)
-    ("\C-c\C-e" . diff-ediff-patch)
-    ("\C-c\C-n" . diff-restrict-view)
-    ("\C-c\C-s" . diff-split-hunk)
-    ("\C-c\C-t" . diff-test-hunk)
-    ("\C-c\C-r" . diff-reverse-direction)
-    ("\C-c\C-u" . diff-context->unified)
-    ;; `d' because it duplicates the context :-(  --Stef
-    ("\C-c\C-d" . diff-unified->context)
-    ("\C-c\C-w" . diff-ignore-whitespace-hunk)
-    ;; `l' because it "refreshes" the hunk like C-l refreshes the screen
-    ("\C-c\C-l" . diff-refresh-hunk)
-    ("\C-c\C-b" . diff-refine-hunk)  ;No reason for `b' :-(
-    ("\C-c\C-f" . next-error-follow-minor-mode))
-  "Keymap for `diff-mode'.  See also `diff-mode-shared-map'.")
+(defvar-keymap diff-mode-shared-map
+  :inherit special-mode-map
+  "n" #'diff-hunk-next
+  "N" #'diff-file-next
+  "p" #'diff-hunk-prev
+  "P" #'diff-file-prev
+  ["TAB"] #'diff-hunk-next
+  [backtab] #'diff-hunk-prev
+  "k" #'diff-hunk-kill
+  "K" #'diff-file-kill
+  "}" #'diff-file-next                  ; From compilation-minor-mode.
+  "{" #'diff-file-prev
+  ["RET"] #'diff-goto-source
+  [mouse-2] #'diff-goto-source
+  "W" #'widen
+  "o" #'diff-goto-source                ; other-window
+  "A" #'diff-ediff-patch
+  "r" #'diff-restrict-view
+  "R" #'diff-reverse-direction
+  [remap undo] #'diff-undo)
+
+(defvar-keymap diff-mode-map
+  :doc "Keymap for `diff-mode'.  See also `diff-mode-shared-map'."
+  ["ESC"] (let ((map (define-keymap :parent diff-mode-shared-map)))
+            ;; We want to inherit most bindings from
+            ;; `diff-mode-shared-map', but not all since they may hide
+            ;; useful `M-<foo>' global bindings when editing.
+            (dolist (key '("A" "r" "R" "g" "q" "W" "z"))
+              (define-key map key nil))
+            map)
+  ;; From compilation-minor-mode.
+  ["C-c C-c"] #'diff-goto-source
+  ;; By analogy with the global C-x 4 a binding.
+  ["C-x 4 A"] #'diff-add-change-log-entries-other-window
+  ;; Misc operations.
+  ["C-c C-a"] #'diff-apply-hunk
+  ["C-c C-e"] #'diff-ediff-patch
+  ["C-c C-n"] #'diff-restrict-view
+  ["C-c C-s"] #'diff-split-hunk
+  ["C-c C-t"] #'diff-test-hunk
+  ["C-c C-r"] #'diff-reverse-direction
+  ["C-c C-u"] #'diff-context->unified
+  ;; `d' because it duplicates the context :-(  --Stef
+  ["C-c C-d"] #'diff-unified->context
+  ["C-c C-w"] #'diff-ignore-whitespace-hunk
+  ;; `l' because it "refreshes" the hunk like C-l refreshes the screen
+  ["C-c C-l"] #'diff-refresh-hunk
+  ["C-c C-b"] #'diff-refine-hunk        ;No reason for `b' :-(
+  ["C-c C-f"] #'next-error-follow-minor-mode)
 
 (easy-menu-define diff-mode-menu diff-mode-map
   "Menu for `diff-mode'."
@@ -269,9 +267,9 @@ and hunk-based syntax highlighting otherwise as a fallback."
   "Prefix key for `diff-minor-mode' commands."
   :type '(choice (string "\e") (string "C-c=") string))
 
-(easy-mmode-defmap diff-minor-mode-map
-  `((,diff-minor-mode-prefix . ,diff-mode-shared-map))
-  "Keymap for `diff-minor-mode'.  See also `diff-mode-shared-map'.")
+(defvar-keymap diff-minor-mode-map
+  :doc "Keymap for `diff-minor-mode'.  See also `diff-mode-shared-map'."
+  diff-minor-mode-prefix diff-mode-shared-map)
 
 (define-minor-mode diff-auto-refine-mode
   "Toggle automatic diff hunk finer highlighting (Diff Auto Refine mode).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]