[Top][All Lists]

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

Re: [Emacs-diffs] emacs-26 ee512e9: Ignore buffers whose name begins wit

From: Eric Abrahamsen
Subject: Re: [Emacs-diffs] emacs-26 ee512e9: Ignore buffers whose name begins with a space in save-some-buffers
Date: Fri, 22 Sep 2017 08:52:30 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> From: Eric Abrahamsen <address@hidden>
>> Date: Thu, 21 Sep 2017 12:57:39 -0700
>> > Are there any upsides and downsides to consider wrt this solution?  If
>> > so, what are they?
>> It isn't so much upsides and downsides, as being careful to add a single
>> bit of functionality, without messing up present behavior and
>> expectations for a highly-trafficked bit of code. I think we can agree:
>> 1. To leave the buffer name out of it (don't handle leading spaces
>>    differently)
>> 2. To require `buffer-offer-save' to be explicitly set non-nil in order
>>    to to consider a non-file buffer for potential saving. I think
>>    Kaushal's right that we should require both `buffer-offer-save' and
>>    `write-contents-functions' to be non-nil
>> 3. To leave the current behavior of the PRED argument unchanged
>> So I think Kaushal's solution is good: it won't change anything at all
>> except to add a clause saying "when `buffer-offer-save' and
>> `write-contents-functions' have been set non-nil, consider the buffer
>> for saving". That's only going to happen when someone explicitly
>> requests it.
> Reusing buffer-offer-save for this purpose sounds a strange solution
> for me.  That variable already says that Emacs should offer saving the
> buffer, and now it will have to do double duty in a convoluted manner.
> It sounds like we are making the problem harder, rather than simpler,
> for modes to solve.

It's appearing twice (which admittedly probably a bad idea), but it
isn't doing double duty: in both cases it simply means that the buffer
should be unilaterally offered for save, regardless of other checks.

> IOW, if we require buffer-offer-save to be non-nil, why do we need to
> also require that write-contents-functions is non-nil?  There are 2
> clauses in the condition we are talking about, both require
> buffer-offer-save to be non-nil, and the only difference between them
> seems to be the condition of buffer size being positive.  Is that what
> write-contents-functions is about -- to allow saving "empty" buffers?

No, it isn't. `write-contents-functions' doesn't need to be in there --
you're right that `buffer-offer-save' should be sufficient -- but then
we'll need to adjust handling of PRED somehow, which is currently being
slightly mis-used as a boolean when Emacs is exiting:

(and pred
       (set-buffer buffer)
       (and buffer-offer-save (> (buffer-size) 0))))

Unless a user has customized `save-some-buffers-default-predicate', PRED
is only t when Emacs is exiting.

I don't understand why it's being used this way, or why
`save-some-buffers' should behave differently when called interactively
vs when Emacs is exiting, but I didn't want to touch it because, as has
been pointed out, it's been this way for decades.

If we can come to a consensus about those two questions, it shouldn't be
hard to come up with a clean solution.

reply via email to

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