aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong <[email protected]>2012-04-26 11:43:32 +0800
committerChong Yidong <[email protected]>2012-04-26 11:43:32 +0800
commit8b71081d301534a7fa4816530f4c3af61c67d038 (patch)
tree4c8fc2c1362233d155e5c06e7fc57d03099413cc
parent0d42eb3e961e612b1b04e32e99c2998dd4d5d3be (diff)
Allow undoing in read-only diff-mode buffers.
* lisp/vc/diff-mode.el (diff-undo): New command. (diff-mode-shared-map): Bind it to / and [remap undo]. Fixes: debbugs:5302
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/vc/diff-mode.el28
2 files changed, 14 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bb40b54279..e7b0a0e1bf 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -14,6 +14,9 @@
2012-04-26 Chong Yidong <[email protected]>
+ * 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).
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index c92371fc90..067fc1c1f2 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -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.