From: Chong Yidong Date: Thu, 26 Apr 2012 03:43:32 +0000 (+0800) Subject: Allow undoing in read-only diff-mode buffers. X-Git-Tag: emacs-24.2.90~471^2~265 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8b71081d301534a7fa4816530f4c3af61c67d038;p=emacs.git 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 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bb40b542792..e7b0a0e1bf6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -14,6 +14,9 @@ 2012-04-26 Chong Yidong + * 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 c92371fc90b..067fc1c1f2b 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.