From a8de88e3300464eb382a65ea96da69f23d21ead2 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 4 Sep 2021 11:14:12 +0200 Subject: [PATCH] Allow killing the diff buffer after `C-x v u' * doc/emacs/maintaining.texi (VC Undo): Document this. * lisp/vc/vc.el (vc-revert-show-diff): Allow a `kill' value. (vc-revert): Use it (bug#16902). --- doc/emacs/maintaining.texi | 18 +++++++++++------- etc/NEWS | 5 +++++ lisp/vc/vc.el | 6 ++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index 008639d1a9a..d17c6d3e757 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi @@ -1136,13 +1136,17 @@ Revert the work file(s) in the current VC fileset to the last revision @findex vc-revert @vindex vc-revert-show-diff If you want to discard all the changes you have made to the current -VC fileset, type @kbd{C-x v u} (@code{vc-revert}). This shows -you a diff between the work file(s) and the revision from which you -started editing, and asks for confirmation for discarding the changes. -If you agree, the fileset is reverted. If you don't want @kbd{C-x v -u} to show a diff, set the variable @code{vc-revert-show-diff} to -@code{nil} (you can still view the diff directly with @kbd{C-x v =}; -@pxref{Old Revisions}). +VC fileset, type @kbd{C-x v u} (@code{vc-revert}). This will ask you +for confirmation before discarding the changes. If you agree, the +fileset is reverted. + + If @code{vc-revert-show-diff} is non-@code{nil}, this command will +show you a diff between the work file(s) and the revision from which +you started editing. Afterwards, the diff buffer will either be +killed (if this variable is @code{kill}), or the buffer will be buried +(any other non-@code{nil} value). If you don't want @kbd{C-x v u} to +show a diff, set this variable to @code{nil} (you can still view the +diff directly with @kbd{C-x v =}; @pxref{Old Revisions}). On locking-based version control systems, @kbd{C-x v u} leaves files unlocked; you must lock again to resume editing. You can also use diff --git a/etc/NEWS b/etc/NEWS index ec81541e655..506eaab0fc0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -997,6 +997,11 @@ keys, add the following to your init file: ** Change Logs and VC ++++ +*** 'vc-revert-show-diff' now has a third possible value: 'kill'. +If this variable is 'kill', then the diff buffer will be killed after +the 'vc-revert' action instead of buried. + *** More VC commands can be used from non-file buffers. The relevant commands are those that don't change the VC state. The non-file buffers which can use VC commands are those that have diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 8036be390a9..f6ae27075f3 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -860,7 +860,9 @@ See `run-hooks'." (defcustom vc-revert-show-diff t "If non-nil, `vc-revert' shows a `vc-diff' buffer before querying." - :type 'boolean + :type '(choice (const :tag "Show and bury afterwards" t) + (const :tag "Show and kill afterwards" kill) + (const :tag "Don't show" nil)) :version "24.1") ;; Header-insertion hair @@ -2757,7 +2759,7 @@ to the working revision (except for keyword expansion)." (if (= nfiles 1) "" "s")))))) (error "Revert canceled"))) (when diff-buffer - (quit-windows-on diff-buffer))) + (quit-windows-on diff-buffer (eq vc-revert-show-diff 'kill)))) (dolist (file files) (message "Reverting %s..." (vc-delistify files)) (vc-revert-file file) -- 2.39.2