emacs-devel
[Top][All Lists]
Advanced

[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 09:54:37 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> (and pred
>>      (progn
>>        (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.
>
> But it's also non-nil in some other cases (e.g. it was non-nil when
> the function was called as a part of running a command in PCL-CVS, and
> presumably the VC-Dir interface should do the same, where the pred` is
> used to only prompt saving of buffers within the relevant directory).

Hence my reluctance to go trampling on the logic! All kinds of packages
must make use of this behavior.

>> If we can come to a consensus about those two questions, it shouldn't be
>> hard to come up with a clean solution.
>
> How 'bout turning buffer-offer-save into a 3-value variable (instead of
> a boolean):
> - nil = as before (i.e. never)
> - t = as before (i.e. only when pred is non-nil and the buffer is not empty)
> - `always` = regardless of pred and buffer's size (i.e. always)

So like this?

(or
 (buffer-file-name buffer)
 (eq buffer-offer-save 'always)
 (and pred
      (progn
        (set-buffer buffer)
        (and buffer-offer-save (> (buffer-size) 0)))))

But think about it from the point of view of documentation: how do you
explain the interaction between `buffer-offer-save' and PRED?

"If b-o-s is t and PRED is t the buffer will be saved, unless b-o-s is
'always in which case it doesn't matter what PRED is, unless PRED is a
function in which case the only thing that matters is what that function
returns, so long as buffer has a file name."

I'm exaggerating for effect, but still. I still don't quite understand
the use of passing a boolean in for PRED.

Maybe we should start by writing the docs, then the code.




reply via email to

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