unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: "Alfred M. Szmidt" <ams@gnu.org>
Cc: 55310@debbugs.gnu.org
Subject: bug#55310: 27.2; vc-revert: unhelpful error message when modified buffers exist
Date: Sun, 08 May 2022 13:44:45 +0200	[thread overview]
Message-ID: <87y1zcjljm.fsf@gnus.org> (raw)
In-Reply-To: <E1nnbY0-0002ze-78@fencepost.gnu.org> (Alfred M. Szmidt's message of "Sun, 08 May 2022 03:41:44 -0400")

"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	other threads:[~2022-05-08 11:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-08  7:41 bug#55310: 27.2; vc-revert: unhelpful error message when modified buffers exist Alfred M. Szmidt
2022-05-08 11:44 ` Lars Ingebrigtsen [this message]
2022-05-08 14:22   ` Alfred M. Szmidt
2022-05-09  9:38     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y1zcjljm.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=55310@debbugs.gnu.org \
    --cc=ams@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).