emacs-diffs
[Top][All Lists]
Advanced

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

emacs-28 575e626: Add symbol property 'save-some-buffers-function' (bug#


From: Juri Linkov
Subject: emacs-28 575e626: Add symbol property 'save-some-buffers-function' (bug#46374)
Date: Sun, 10 Oct 2021 13:38:31 -0400 (EDT)

branch: emacs-28
commit 575e626105b506b008eb9b0a03bb27aeecee54d4
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    Add symbol property 'save-some-buffers-function' (bug#46374)
    
    * lisp/files.el (save-some-buffers-root): Put non-nil
    symbol property 'save-some-buffers-function'.
    (save-some-buffers): Check pred for the
    symbol property 'save-some-buffers-function'.
    (save-some-buffers-default-predicate): Mention
    symbol property 'save-some-buffers-function'.
---
 lisp/files.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 64c69e6..7f9e9f5 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5745,7 +5745,9 @@ This allows you to stop `save-some-buffers' from asking
 about certain files that you'd usually rather not save.
 
 This function is called (with no parameters) from the buffer to
-be saved."
+be saved.  When the function's symbol has the property
+`save-some-buffers-function', the higher-order function is supposed
+to return a predicate used to check buffers."
   :group 'auto-save
   ;; FIXME nil should not be a valid option, let alone the default,
   ;; eg so that add-function can be used.
@@ -5765,6 +5767,7 @@ of the directory that was default during command 
invocation."
                        (project-root (project-current)))
                   default-directory)))
     (lambda () (file-in-directory-p default-directory root))))
+(put 'save-some-buffers-root 'save-some-buffers-function t)
 
 (defun save-some-buffers (&optional arg pred)
   "Save some modified file-visiting buffers.  Asks user about each one.
@@ -5796,9 +5799,10 @@ change the additional actions you can take on files."
     (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).
-  (let ((pred-fun (and (functionp pred) (funcall pred))))
-    (when (functionp pred-fun)
-      (setq pred pred-fun)))
+  (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))))
   (let* ((switched-buffer nil)
          (save-some-buffers--switch-window-callback
           (lambda (buffer)



reply via email to

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