bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55310: 27.2; vc-revert: unhelpful error message when modified buffer


From: Lars Ingebrigtsen
Subject: bug#55310: 27.2; vc-revert: unhelpful error message when modified buffers exist
Date: Sun, 08 May 2022 13:44:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

"Alfred M. Szmidt" <ams@gnu.org> writes:

> When doing vc-revert in a vc-dir buffer, and when one has a bunch of
> open files, one somtimes gets the unhelpful message:
>
>   vc-revert: Please kill or save all modified buffers before reverting
>
> Nicer would be prompting the user to kill/save those buffers, or list them.

I don't think we want to have an interface that offers to kill buffers
in a loop -- it sounds like something that's really error-prone, which
is why that code is the way it is, I think.  (To make the user make the
decision themselves explicitly.)

We could do this, of course:

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 3508f684c4..cb5e42db4c 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -2780,6 +2780,10 @@ vc-revert
     ;; show the changes and ask for confirmation to discard them.
     (when (or (not files) (memq (buffer-file-name) files))
       (vc-buffer-sync nil))
+    ;; Offer to save all the buffers we're reverting.
+    (save-some-buffers
+     nil (lambda ()
+           (member (buffer-file-name) files)))
     (dolist (file files)
       (let ((buf (get-file-buffer file)))
        (when (and buf (buffer-modified-p buf))


But if the user answers "no", then it'll just signal an error anyway, so
that's just confusing.

So I think leaving it the way it is is the best option here, since this
command is one of the most potentially destructive ones we have in
Emacs.  Anybody have an opinion here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]