aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Whitton2025-11-13 16:22:20 +0000
committerSean Whitton2025-11-13 16:22:20 +0000
commit5dfcba699e1a59be97e22a6f33fa5dfe59a4db9f (patch)
tree0ef16b70e3db0dc369c6c8efc1371cc79fce2836
parenta0c69d3d44f073fbd8f1ffb2a5a8641d37f80039 (diff)
downloademacs-5dfcba699e1a59be97e22a6f33fa5dfe59a4db9f.tar.gz
emacs-5dfcba699e1a59be97e22a6f33fa5dfe59a4db9f.zip
Revised bindings for diff-revert-and-kill-hunk
* lisp/vc/diff-mode.el (diff-mode-shared-map): Bind diff-revert-and-kill-hunk to 'u'. (diff-mode-map): Replace binding for diff-revert-and-kill-hunk with 'C-c M-u'. * doc/emacs/files.texi (Diff Mode): * etc/NEWS: Document the change.
-rw-r--r--doc/emacs/files.texi2
-rw-r--r--etc/NEWS2
-rw-r--r--lisp/vc/diff-mode.el11
3 files changed, 11 insertions, 4 deletions
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
1825hunk to the ``old'' version of the file instead. 1825hunk to the ``old'' version of the file instead.
1826 1826
1827@findex diff-revert-and-kill-hunk 1827@findex diff-revert-and-kill-hunk
1828@item C-c M-r 1828@item C-c M-u
1829Revert this hunk, and then remove the hunk from the diffs 1829Revert this hunk, and then remove the hunk from the diffs
1830(@code{diff-revert-and-kill-hunk}). Save the buffer visiting the target 1830(@code{diff-revert-and-kill-hunk}). Save the buffer visiting the target
1831file. 1831file.
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
2003command attempts to look up and copy the text in between the hunks. 2003command attempts to look up and copy the text in between the hunks.
2004 2004
2005+++ 2005+++
2006*** New command 'diff-revert-and-kill-hunk' bound to 'C-c M-r'. 2006*** New command 'diff-revert-and-kill-hunk' bound to 'u' and 'C-c M-u'.
2007This command reverts the hunk at point (i.e., applies the reverse of the 2007This command reverts the hunk at point (i.e., applies the reverse of the
2008hunk), and then removes the hunk from the diffs. 2008hunk), and then removes the hunk from the diffs.
2009This is useful to undo or revert changes, committed and uncommitted, when 2009This 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'."
221 "A" #'diff-ediff-patch 221 "A" #'diff-ediff-patch
222 "r" #'diff-restrict-view 222 "r" #'diff-restrict-view
223 "R" #'diff-reverse-direction 223 "R" #'diff-reverse-direction
224 "<remap> <undo>" #'diff-undo) 224 "<remap> <undo>" #'diff-undo
225
226 ;; The foregoing commands don't affect buffers beyond this one.
227 ;; The following command is the only one that has a single-letter
228 ;; binding and which affects buffers beyond this one.
229 ;; However, the following command asks for confirmation by default,
230 ;; so that seems okay. --spwhitton
231 "u" #'diff-revert-and-kill-hunk)
225 232
226(defvar-keymap diff-mode-map 233(defvar-keymap diff-mode-map
227 :doc "Keymap for `diff-mode'. See also `diff-mode-shared-map'." 234 :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'."
238 "C-x 4 A" #'diff-add-change-log-entries-other-window 245 "C-x 4 A" #'diff-add-change-log-entries-other-window
239 ;; Misc operations. 246 ;; Misc operations.
240 "C-c C-a" #'diff-apply-hunk 247 "C-c C-a" #'diff-apply-hunk
241 "C-c M-r" #'diff-revert-and-kill-hunk 248 "C-c M-u" #'diff-revert-and-kill-hunk
242 "C-c C-m a" #'diff-apply-buffer 249 "C-c C-m a" #'diff-apply-buffer
243 "C-c C-m n" #'diff-delete-other-hunks 250 "C-c C-m n" #'diff-delete-other-hunks
244 "C-c C-e" #'diff-ediff-patch 251 "C-c C-e" #'diff-ediff-patch