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

From: Juri Linkov <[email-masked]>
Date: Wed, 17 Mar 2021 19:10:15 +0200

> How 'bout using something like `isearch-search-fun-function`:
> i.e. *compute* the predicate by calling
> save-some-buffers-predicate-function, so this function can return
> a predicate that remembers the default-dir of the original buffer (or
> any other aspect relevant to the state from which we started the
> save-some-buffers).

This should work.  Then in save-some-buffers it's possible
to add after the existing 2 lines:

  (unless pred
    (setq pred save-some-buffers-default-predicate))

only 3 additional lines:

  (let ((pred-fun (and (functionp pred) (funcall pred))))
    (when (functionp pred-fun)
      (setq pred pred-fun)))

Then a pred function could contain something like:

  (lambda ()
    (let ((project-dir (or (project-root (project-current)) default-directory)))
      (lambda () (file-in-directory-p default-directory project-dir))))