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).
This commit is contained in:
Lars Ingebrigtsen 2021-09-04 11:14:12 +02:00
parent 56c98a4ad8
commit a8de88e330
3 changed files with 20 additions and 9 deletions

View file

@ -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

View file

@ -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

View file

@ -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)