emacs-diffs
[Top][All Lists]
Advanced

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

emacs-28 74223bbdaf: (save-some-buffers): Simplify the fix for bug#46374


From: Stefan Monnier
Subject: emacs-28 74223bbdaf: (save-some-buffers): Simplify the fix for bug#46374
Date: Sun, 9 Jan 2022 22:18:21 -0500 (EST)

branch: emacs-28
commit 74223bbdaff7533709fe6e81837e09d98320c1ee
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    (save-some-buffers): Simplify the fix for bug#46374
    
    * lisp/files.el (save-some-buffers): Only check the
    `save-some-buffers-function` property on functions from
    `save-some-buffers-default-predicate` since callers which provide
    a `pred` argument can arrange to compute `pred` themselves if needed.
    
    * test/lisp/files-tests.el (files-tests-buffer-offer-save): Don't test
    with `pred` set to `save-some-buffers-root` since it's not an
    appropriate function for that any more.
---
 lisp/files.el            | 21 +++++++++++----------
 test/lisp/files-tests.el |  2 +-
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 9a7b26ee03..888c2d3784 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5755,7 +5755,7 @@ to return a predicate used to check buffers."
   ;; FIXME nil should not be a valid option, let alone the default,
   ;; eg so that add-function can be used.
   :type '(choice (const :tag "Default" nil)
-                 (function :tag "Only in subdirs of root"
+                 (function :tag "Only in subdirs of current project"
                            save-some-buffers-root)
                  (function :tag "Custom function"))
   :version "26.1")
@@ -5791,21 +5791,22 @@ all with no questions.
 Optional second argument PRED determines which buffers are considered:
 If PRED is nil, all the file-visiting buffers are considered.
 If PRED is t, then certain non-file buffers will also be considered.
-If PRED is a zero-argument function, it indicates for each buffer whether
-to consider it or not when called with that buffer current.
+If PRED is a function, it is called with no argument in each buffer and
+should return non-nil if that buffer should be considered.
 PRED defaults to the value of `save-some-buffers-default-predicate'.
 
 See `save-some-buffers-action-alist' if you want to
 change the additional actions you can take on files."
   (interactive "P")
   (unless pred
-    (setq pred save-some-buffers-default-predicate))
-  ;; Allow `pred' to be a function that returns a predicate
-  ;; with lexical bindings in its original environment (bug#46374).
-  (when (and (symbolp pred) (get pred 'save-some-buffers-function))
-    (let ((pred-fun (and (functionp pred) (funcall pred))))
-      (when (functionp pred-fun)
-        (setq pred pred-fun))))
+    (setq pred
+          ;; Allow `pred' to be a function that returns a predicate
+          ;; with lexical bindings in its original environment (bug#46374).
+          (if (and (symbolp save-some-buffers-default-predicate)
+                   (get save-some-buffers-default-predicate
+                        'save-some-buffers-function))
+              (funcall save-some-buffers-default-predicate)
+            save-some-buffers-default-predicate)))
   (let* ((switched-buffer nil)
          (save-some-buffers--switch-window-callback
           (lambda (buffer)
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 57597762af..be9339a8f5 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -1769,7 +1769,7 @@ PRED is nil."
     (files-tests-with-all-permutations
         buffers-offer
         buffers-offer-init
-      (dolist (pred `(nil t save-some-buffers-root))
+      (dolist (pred `(nil t))
         (dolist (callers-dir `(nil save-some-buffers-root))
           (let* ((head-offer (cadar buffers-offer))
                  (res (cond ((null pred)



reply via email to

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