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: Tue, 16 Mar 2021 19:49:27 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> OK, back to my original implementation (i.e., adding a new option
>> to `save-some-buffers-default-predicate`).
>
> Is it a problem that such separate function can't get
> information about the original default-directory when
> called as: (with-current-buffer buffer (funcall pred))?
>
> Actually, this is the shortcoming of the old design of
> save-some-buffers-default-predicate.  Is it possible to add
> a new arg (with an original dir) to the predicate function?
> Then for backward-compatibility before calling it, the function arity
> could be checked, then called with one arg when it's accepted
> by the function, otherwise call without args.

I meant to replace in 'save-some-buffers'

  (with-current-buffer buffer (funcall pred))

with

  (let ((one-arg (equal (func-arity pred) '(1 . 1))))
    (dolist (buffer (buffer-list))
      (if one-arg
          (funcall pred buffer)
        (with-current-buffer buffer (funcall pred))))

Then 'default-directory' of the original buffer will be preserved
inside the pred function, so it will be possible to call the pred function
with one arg 'buffer' and check whether the buffer is under the original
'default-directory' with

  (file-in-directory-p (buffer-local-value 'default-directory buffer)
                       default-directory)





reply via email to

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