]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow undoing in read-only diff-mode buffers.
authorChong Yidong <cyd@gnu.org>
Thu, 26 Apr 2012 03:43:32 +0000 (11:43 +0800)
committerChong Yidong <cyd@gnu.org>
Thu, 26 Apr 2012 03:43:32 +0000 (11:43 +0800)
* lisp/vc/diff-mode.el (diff-undo): New command.
(diff-mode-shared-map): Bind it to / and [remap undo].

Fixes: debbugs:5302
lisp/ChangeLog
lisp/vc/diff-mode.el

index bb40b5427928fd7144fc225ebc84d14c68975397..e7b0a0e1bf63ccde44c2402da5e1e84b0b5c3bb6 100644 (file)
@@ -14,6 +14,9 @@
 
 2012-04-26  Chong Yidong  <cyd@gnu.org>
 
+       * vc/diff-mode.el (diff-undo): New command (Bug#5302).
+       (diff-mode-shared-map): Bind it to / and [remap undo].
+
        * vc/ediff-wind.el (ediff-setup-windows-default): New function.
        (ediff-window-setup-function): Use it as the default, to set up
        windows based on whether the current frame is graphical (Bug#2138).
index c92371fc90befc0bbcda3df35094644fcd13d60e..067fc1c1f2baad87656fe0c7ce0cfe9d0ae8edb4 100644 (file)
@@ -107,8 +107,7 @@ when editing big diffs)."
 ;;;;
 
 (easy-mmode-defmap diff-mode-shared-map
-  '(;; From Pavel Machek's patch-mode.
-    ("n" . diff-hunk-next)
+  '(("n" . diff-hunk-next)
     ("N" . diff-file-next)
     ("p" . diff-hunk-prev)
     ("P" . diff-file-prev)
@@ -116,27 +115,17 @@ when editing big diffs)."
     ([backtab] . diff-hunk-prev)
     ("k" . diff-hunk-kill)
     ("K" . diff-file-kill)
-    ;; From compilation-minor-mode.
-    ("}" . diff-file-next)
+    ("}" . diff-file-next)     ; From compilation-minor-mode.
     ("{" . diff-file-prev)
     ("\C-m" . diff-goto-source)
     ([mouse-2] . diff-goto-source)
-    ;; From XEmacs's diff-mode.
     ("W" . widen)
-    ;;("." . diff-goto-source)         ;display-buffer
-    ;;("f" . diff-goto-source)         ;find-file
-    ("o" . diff-goto-source)           ;other-window
-    ;;("w" . diff-goto-source)         ;other-frame
-    ;;("N" . diff-narrow)
-    ;;("h" . diff-show-header)
-    ;;("j" . diff-show-difference)     ;jump to Nth diff
-    ;;("q" . diff-quit)
-    ;; Not useful if you have to metafy them.
-    ;;(" " . scroll-up)
-    ;;("\177" . scroll-down)
+    ("o" . diff-goto-source)   ; other-window
     ("A" . diff-ediff-patch)
     ("r" . diff-restrict-view)
-    ("R" . diff-reverse-direction))
+    ("R" . diff-reverse-direction)
+    ("/" . diff-undo)
+    ([remap undo] . diff-undo))
   "Basic keymap for `diff-mode', bound to various prefix keys."
   :inherit special-mode-map)
 
@@ -1904,6 +1893,11 @@ For use in `add-log-current-defun-function'."
                                   (match-end 0) end
                                   props 'diff-refine-preproc))))))))
 
+(defun diff-undo (&optional arg)
+  "Perform `undo', ignoring the buffer's read-only status."
+  (interactive "P")
+  (let ((inhibit-read-only t))
+    (undo arg)))
 
 (defun diff-add-change-log-entries-other-window ()
   "Iterate through the current diff and create ChangeLog entries.