GNU bug report logs -
#46374
28.0.50; Ask me to save buffers only if they are under callers dir
Previous Next
Reported by: Tino Calancha <tino.calancha <at> gmail.com>
Date: Sun, 7 Feb 2021 22:33:01 UTC
Severity: wishlist
Tags: fixed
Merged with 50380
Fixed in version 28.0.60
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> I have found a way to merge the two approaches. Not sure if
> idiomatic, but it works.
>
> [The patch omits NEWS entry and documentation; I will add those once we
> found the implementation]
Thanks, now your patch is taking a good shape. I'm testing it now.
Here is a condensed version of your patch to think about it.
#+begin_src emacs-lisp
(defvar save-some-buffers-default-fun (lambda () nil))
(defvar save-some-buffers-in-current-project-fun
(lambda ()
(let ((project-dir (or (and (project-current) (project-root (project-current)))
default-directory)))
(lambda () (file-in-directory-p default-directory project-dir)))))
(defcustom save-some-buffers-default-predicate save-some-buffers-default-fun
:type `(choice
(function :tag "All buffers" :value ,save-some-buffers-default-fun)
(function :tag "Buffers inside current project"
:value ,save-some-buffers-in-current-project-fun)))
(defun save-some-buffers-fun ()
(funcall save-some-buffers-default-predicate))
(defun save-some-buffers (&optional arg pred)
(unless pred
(setq pred (save-some-buffers-fun)))
#+end_src
I see a problem in save-some-buffers-fun: what if
save-some-buffers-default-predicate is still customized to nil?
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.
This bug report was last modified 3 years and 191 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.