diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 28234fbec9c..f677804b6a4 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -1825,7 +1825,7 @@ version. If @code{diff-jump-to-old-file} is non-@code{nil}, apply the hunk to the ``old'' version of the file instead. @findex diff-revert-and-kill-hunk -@item C-c M-r +@item C-c M-u Revert this hunk, and then remove the hunk from the diffs (@code{diff-revert-and-kill-hunk}). Save the buffer visiting the target file. diff --git a/etc/NEWS b/etc/NEWS index 7168cc5bb92..1a0589fd23d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2003,7 +2003,7 @@ to the original text. If the selected range extends a hunk, the command attempts to look up and copy the text in between the hunks. +++ -*** New command 'diff-revert-and-kill-hunk' bound to 'C-c M-r'. +*** New command 'diff-revert-and-kill-hunk' bound to 'u' and 'C-c M-u'. This command reverts the hunk at point (i.e., applies the reverse of the hunk), and then removes the hunk from the diffs. This is useful to undo or revert changes, committed and uncommitted, when diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index f3810f7754d..7dd90ee5b75 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -221,7 +221,14 @@ and with a `diff-minor-mode-prefix' prefix in `diff-minor-mode'." "A" #'diff-ediff-patch "r" #'diff-restrict-view "R" #'diff-reverse-direction - " " #'diff-undo) + " " #'diff-undo + + ;; The foregoing commands don't affect buffers beyond this one. + ;; The following command is the only one that has a single-letter + ;; binding and which affects buffers beyond this one. + ;; However, the following command asks for confirmation by default, + ;; so that seems okay. --spwhitton + "u" #'diff-revert-and-kill-hunk) (defvar-keymap diff-mode-map :doc "Keymap for `diff-mode'. See also `diff-mode-shared-map'." @@ -238,7 +245,7 @@ and with a `diff-minor-mode-prefix' prefix in `diff-minor-mode'." "C-x 4 A" #'diff-add-change-log-entries-other-window ;; Misc operations. "C-c C-a" #'diff-apply-hunk - "C-c M-r" #'diff-revert-and-kill-hunk + "C-c M-u" #'diff-revert-and-kill-hunk "C-c C-m a" #'diff-apply-buffer "C-c C-m n" #'diff-delete-other-hunks "C-c C-e" #'diff-ediff-patch