Subject: bug#55310: 27.2; vc-revert: unhelpful error message when modified buffers exist

From: Dmitry Gutov <[email-masked]>
Date: Sat, 15 Mar 2025 04:18:59 +0200

On 14/03/2025 05:37, Sean Whitton wrote:
> Hello,
> 
> On Wed 12 Mar 2025 at 10:11am +02, Dmitry Gutov wrote:
> 
>> On 10/03/2025 09:06, Sean Whitton wrote:
>>>>> Idea (ideas are cheap): maybe if one could add some sort of
>>>>> high-light, or something in vc-dired that shows that this or that file
>>>>> has a open buffer that is unmodified, and then the error could be the
>>>>> same but just saying that one should check the highlighted buffers.
>>>> I think that's a good idea -- perhaps Dmitry has some comments; added to
>>>> the CCs.
>>> ISTM that a project-save-some-buffers is what's wanted here.
>>> Dmitry, has there been a discussion about having something like that?
>>
>> Last time this came up, a new value for save-some-buffers-default-predicate
>> was added: save-some-buffers-root (bug#46374). So:
>>
>>    (setopt save-some-buffers-default-predicate #'save-some-buffers-root)
> 
> Ah, thanks for the reference.
> 
> I would like to do one of the following things:
> 
> (1) Do add the call to save-some-buffers in Lars's message.
>      We can change the error message to
>        "Some unsaved buffers remain; cannot revert"
>      and then I don't agree with him that the situation is confusing.

Re-reading the discussion again, maybe Lars's original suggestion - from 
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55310#8 - is better?

This way we'd only require that the buffers to be reverted, are saved. 
And abort otherwise.

Also probably change the error to something like

   "Please kill or save all affected buffers before reverting"

If we can't print all the buffer names, which we also could try, though.

Requiring all buffers across the project (never mind the session) to be 
saved before any can be vc-reverted, would be a more disruptive change.

> (2) Add a project-save-some-buffers which just binds
>      save-some-buffers-default-predicate around a call to
>      save-some-buffers, bind is to 'C-x p C-x s' (useful anyway, I think)
>      and change the message to suggest using it:
>        "Use C-x p C-x s to save or kill modified buffers before reverting"

Adding a new command with a binding sounds good to me, irrespective of 
this issue.