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

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

bug#46374: 28.0.50; Ask me to save buffers only if they are under caller


From: Juri Linkov
Subject: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir
Date: Thu, 29 Apr 2021 19:04:49 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> I see a problem in save-some-buffers-fun: what if
>> save-some-buffers-default-predicate is still customized to nil?
> I assumed we were OK with the backward incompatible change; I mean,
> with requiring from now on `save-some-buffers-default-predicate'
> to be a function generating the predicate.
>
>> This value is currently allowed.  It seems it should check
>> if it's a function, then call it.  Also needs to check if the function
>> doesn't return another lambda, then return its original value.
> We can do that; but it seems to me that the spirit of the FIXME comment
> is in the line to not accept `nil' as a valid value, just functions.

Indeed, to remove the FIXME comment we could set the default value to
'ignore' that returns nil:

  (funcall (lambda () nil)) => nil
  (funcall 'ignore)         => nil

But also it's easy to support the old value 'nil', and also
support old functions that don't return a predicate.
You can just return the same value if it's not a function,
and also return the function if it doesn't return a predicate.
Something like this (untested):

  (defun save-some-buffers-fun ()
    (if (functionp save-some-buffers-default-predicate)
        (let ((ret (funcall save-some-buffers-default-predicate)))
          (if (functionp ret) ret save-some-buffers-default-predicate))
      save-some-buffers-default-predicate))





reply via email to

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