From unknown Sat Aug 16 21:18:13 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#46374 <46374@debbugs.gnu.org> To: bug#46374 <46374@debbugs.gnu.org> Subject: Status: 28.0.50; Ask me to save buffers only if they are under callers dir Reply-To: bug#46374 <46374@debbugs.gnu.org> Date: Sun, 17 Aug 2025 04:18:13 +0000 retitle 46374 28.0.50; Ask me to save buffers only if they are under caller= s dir reassign 46374 emacs submitter 46374 Tino Calancha severity 46374 wishlist tag 46374 fixed thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 07 17:32:27 2021 Received: (at submit) by debbugs.gnu.org; 7 Feb 2021 22:32:27 +0000 Received: from localhost ([127.0.0.1]:49159 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8sbN-0001XM-Jf for submit@debbugs.gnu.org; Sun, 07 Feb 2021 17:32:27 -0500 Received: from lists.gnu.org ([209.51.188.17]:34452) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8sbL-0001XF-UB for submit@debbugs.gnu.org; Sun, 07 Feb 2021 17:32:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8sbK-00055R-7Z for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2021 17:32:19 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:40983) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8sbG-0006pY-1Y for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2021 17:32:17 -0500 Received: by mail-wr1-x42b.google.com with SMTP id n6so2234462wrv.8 for ; Sun, 07 Feb 2021 14:32:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=BdyVHx8BMSFEXYxfVA9K/+uIVBju6cgJ0GimU7Gu7+s=; b=OhbB3z54EQcUcYiMOVr6S1dlCb4n1Wg5l88kpdIMAHmQAn3Xu6deFam3WX/+3um+IC kfRbpEVB3+M7HFf/kI8rhDW4GYlY+4uM29q7alcq+CbFMfNks0Rn7AZ7kK3j//uUUy9z RSeSqAT4RjcvmJwdLMTp+AygWRGTxbqBaq4Bsv+6rvF9UefvFCjOcH6LKU7M7wjAJFGF COUZv9SUZi0hi8g0GF73IO83qxwOwC2IZTkusQOI444u5eU6joTnpnQIQ9OjHxT1/Hb5 O4vs5WQn9Us0Mxg1JK9YxEP3iHA5JHrp59aGyNcth24XkXY+6xRt69TGbPTJBLD88a0Q /pog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=BdyVHx8BMSFEXYxfVA9K/+uIVBju6cgJ0GimU7Gu7+s=; b=C0Gtl/0Rsvj9vrcrsmqLp8cObtwz+MwIgj2+WM4uMuHJXZDxrcEHrR8YjdbQfdrhoC mi83KwkpunWHSEhywOjjGtQv5fQrPUmxlrCD9PIDhVRhutz7zFYel6VPSVLWKIULpWyZ wIFWG35C80IYLYAqigJz9fQ7zrVjO28BrAS2PzndXeW9bgWv0CmkMWgFqEZwBv7AN5jb s2Ny+881F+/5xEamxN32GeK8R5Pt/c284/ZBZIviB4qUR0DviwXJx/eYvatOYauzLdJR zxRo9H0mhrEFUoodI7Lttf8dxdloyFfPYMIHHorNwYPz9Fmfp+d9q868aRE+WyX7HLN4 BGqw== X-Gm-Message-State: AOAM533ca9XK/a0MMYyVgN6Opl5YbSSr+G/lCTKcUavxDuWBCz+Mm3cd 7wCf0a2MNVUQC31t0yanxKDxy5ohB9I= X-Google-Smtp-Source: ABdhPJyEkXclcVsKpQqPzGfHX8sxqU44/hLZYqbQy/RaNbgY/2pRyZnC5ltPSPKi2Qpw6xJMQDVv5g== X-Received: by 2002:a05:6000:18a3:: with SMTP id b3mr16790532wri.373.1612737130063; Sun, 07 Feb 2021 14:32:10 -0800 (PST) Received: from localhost.example.com ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id b2sm4698777wrv.73.2021.02.07.14.32.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 14:32:09 -0800 (PST) From: Tino Calancha To: bug-gnu-emacs@gnu.org Subject: 28.0.50; Ask me to save buffers only if they are under callers dir Date: Sun, 07 Feb 2021 23:32:07 +0100 Message-ID: <878s7z4ihk.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=tino.calancha@gmail.com; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) X-Debbugs-Cc: Stefan Monnier , Severity: wishlist Severity: patch I wish, by default, to only been prompted for buffers whose default-directory is under the caller dir (except when closing Emacs). ## Description Everyday I connect via Tramp with machines at each of my properties (Hawaii, Maldives, Palawan, and a very large etc.) Then, in the same Emacs session, I connect to a host in Wall Street to see how my stock grows, making me richer. Often, a compilation buffer at New York city prompts me to save a buffer at Waikiki beach. Quite distracting! Cannot focus on my money! I found some people with related issues: https://emacs.stackexchange.com/questions/7268/package-el-asks-whether-i-want-to-save-modified-files-before-package-installatio https://emacs.stackexchange.com/questions/40593/automatically-dont-save-buffers-before-compiling ## How to reproduce Sure, I understand not all of you can possibly reproduce the above conditions. Maybe you can try the following poor man's recipe: emacs -Q ~/foo.txt ;; write something and do not save foo ;; now visit another, for instance, the Emacs source dir C-x d EMACS-SRC-DIR RET ;; call rgrep with whatever string M-x rgrep money RET *.el RET RET ;; You will be prompted to save ~/foo.txt I am aware of `grep-save-buffers', `compilation-save-buffers-predicate' and the solutions proposed in the links above. My proposal adds a new option `save-some-buffers-restrict-to-caller-subdirs'. I am already using it for a while with joy (10 bagger at GameStop using it!). --8<-----------------------------cut here---------------start------------->8--- commit 85e5399f035fb698fcfbb50ca01980fbbc68707c Author: Tino Calancha Date: Thu Feb 4 21:39:37 2021 +0100 save-some-buffers: Add option restricting to files in a caller's subdir Restrict the action to buffers with `default-directory' lying in a subdir of the `default-directory' from where the command is invoked. * lisp/files.el (save-some-buffers-restrict-to-caller-subdirs): New option. (save-some-buffers) (save-buffers-kill-emacs): Use it. * doc/emacs/files.texi (Save Commands) * doc/lispref/files.texi (Saving Buffers): Document it. * etc/NEWS (Editing Changes in Emacs 28.1): Announce this change. * lisp/progmodes/grep.el (grep-save-buffers) * lisp/progmodes/compile.el (compilation-save-buffers-predicate): Mention it in the docstring. * test/lisp/files-tests.el (files-tests--save-some-buffers): Helper function. (files-tests-with-all-permutations) (files-tests--with-buffer-offer-save): Helper macros. (files-tests-save-some-buffers) (files-tests-buffer-offer-save) (files-tests-save-buffers-kill-emacs--asks-to-save-buffers): New tests. diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 6b3bc430d9..36d38218e9 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -433,9 +433,11 @@ Save Commands @noindent @vindex save-some-buffers-default-predicate +@vindex save-some-buffers-restrict-to-caller-subdirs You can customize the value of -@code{save-some-buffers-default-predicate} to control which buffers -Emacs will ask about. +@code{save-some-buffers-default-predicate} and +@code{save-some-buffers-restrict-to-caller-subdirs} to control which +buffers Emacs will ask about. @kbd{C-x C-c}, the key sequence to exit Emacs, invokes @code{save-some-buffers} and therefore asks the same questions. diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 4110c51099..a9855fef2b 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi @@ -371,6 +371,7 @@ Saving Buffers querying the user. @vindex save-some-buffers-default-predicate +@vindex save-some-buffers-restrict-to-caller-subdirs The optional @var{pred} argument provides a predicate that controls which buffers to ask about (or to save silently if @var{save-silently-p} is non-@code{nil}). If @var{pred} is @@ -381,8 +382,12 @@ Saving Buffers other non-file buffers---those that have a non-@code{nil} buffer-local value of @code{buffer-offer-save} (@pxref{Killing Buffers}). A user who says @samp{yes} to saving a non-file buffer is asked to specify -the file name to use. The @code{save-buffers-kill-emacs} function -passes the value @code{t} for @var{pred}. +the file name to use. The option +@code{save-some-buffers-restrict-to-caller-subdirs} restricts the +action of this command to buffers with @code{default-directory} in a +subdirectory of the caller's @code{default-directory}. The +@code{save-buffers-kill-emacs} function ignores this option and passes +the value @code{t} for @var{pred}. If the predicate is neither @code{t} nor @code{nil}, then it should be a function of no arguments. It will be called in each buffer to decide diff --git a/etc/NEWS b/etc/NEWS index b3d53bf73c..f1bd21f26a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -247,6 +247,11 @@ commands. The new keystrokes are 'C-x x g' ('revert-buffer'), * Editing Changes in Emacs 28.1 ++++ +** The new option 'save-some-buffers-restrict-to-caller-subdirs' +restricts the action of 'same-some-buffers' to buffers with +'default-directory' in a subdir of the callers 'default-directory'. + --- ** 'eval-expression' now no longer signals an error on incomplete expressions. Previously, typing 'M-: ( RET' would result in Emacs saying "End of diff --git a/lisp/files.el b/lisp/files.el index dada69c145..d51cd58217 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5520,6 +5520,19 @@ save-some-buffers-default-predicate :type '(choice (const :tag "Default" nil) function) :version "26.1") +(defcustom save-some-buffers-restrict-to-caller-subdirs nil + "Only save buffers under caller's default directory. +I.e., only prompt for modified buffers whose `default-directory' is in +in a subdir of the directory from where `save-some-buffers' is +invoked. +Note that `save-buffers-kill-emacs' ignores this value and prompts for +any unsaved buffer." + :group 'auto-save + :type '(choice + (const :tag "All buffers" nil) + (const :tag "Buffers under caller's default directory" t)) + :version "28.1") + (defun save-some-buffers (&optional arg pred) "Save some modified file-visiting buffers. Asks user about each one. You can answer `y' or SPC to save, `n' or DEL not to save, `C-r' @@ -5543,12 +5556,35 @@ save-some-buffers to consider it or not when called with that buffer current. PRED defaults to the value of `save-some-buffers-default-predicate'. +You can restrict to modified buffers with `default-directory' under +the caller's `default-directory' with +`save-some-buffers-restrict-to-caller-subdirs'. + 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)) - (let* ((switched-buffer nil) + (let* ((caller-dir default-directory) + (maybe-save-buffer-p + (lambda (buffer) + (or (not save-some-buffers-restrict-to-caller-subdirs) + (file-in-directory-p (buffer-local-value 'default-directory buffer) + caller-dir)))) + (effective-pred + (unless (eq t pred) + (let ((def-pred save-some-buffers-default-predicate)) + (lambda () (and (funcall maybe-save-buffer-p (current-buffer)) + (if (functionp pred) (funcall pred) + (or (not (functionp def-pred)) + (funcall def-pred)))))))) + (switched-buffer nil) + (non-visiting-buffers-ok (not (null pred))) + (buffer-name-matches-filename-p + (lambda (buffer) + "Return non-nil if BUFFER name is similar to its file name." + (let ((file-basename (file-name-nondirectory (buffer-file-name buffer)))) + (or (equal (buffer-name buffer) file-basename) + (string-match-p (format "\\<%s<[^>]*>\\'" (regexp-quote file-basename)) + (buffer-name buffer)))))) (save-some-buffers--switch-window-callback (lambda (buffer) (setq switched-buffer buffer))) @@ -5578,36 +5614,20 @@ save-some-buffers (buffer-file-name buffer) (with-current-buffer buffer (or (eq buffer-offer-save 'always) - (and pred buffer-offer-save - (> (buffer-size) 0))))) - (or (not (functionp pred)) - (with-current-buffer buffer (funcall pred))) + (and non-visiting-buffers-ok buffer-offer-save (> (buffer-size) 0))))) + (or (not (functionp effective-pred)) + (with-current-buffer buffer (funcall effective-pred))) (if arg - t + (funcall maybe-save-buffer-p buffer) (setq queried t) - (if (buffer-file-name buffer) - (if (or - (equal (buffer-name buffer) - (file-name-nondirectory - (buffer-file-name buffer))) - (string-match - (concat "\\<" - (regexp-quote - (file-name-nondirectory - (buffer-file-name buffer))) - "<[^>]*>\\'") - (buffer-name buffer))) - ;; The buffer name is similar to the - ;; file name. - (format "Save file %s? " - (buffer-file-name buffer)) - ;; The buffer and file names are - ;; dissimilar; display both. - (format "Save file %s (buffer %s)? " - (buffer-file-name buffer) - (buffer-name buffer))) - ;; No file name - (format "Save buffer %s? " (buffer-name buffer)))))) + (when (funcall maybe-save-buffer-p buffer) + (cond ((null (buffer-file-name buffer)) + (format "Save buffer %s? " (buffer-name buffer))) + ((funcall buffer-name-matches-filename-p buffer) + (format "Save file %s? " (buffer-file-name buffer))) + (t (format "Save file %s (buffer %s)? " + (buffer-file-name buffer) + (buffer-name buffer)))))))) (lambda (buffer) (with-current-buffer buffer (save-buffer))) @@ -7362,7 +7382,8 @@ save-buffers-kill-emacs (interactive "P") ;; Don't use save-some-buffers-default-predicate, because we want ;; to ask about all the buffers before killing Emacs. - (save-some-buffers arg t) + (let ((save-some-buffers-restrict-to-caller-subdirs nil)) + (save-some-buffers arg t)) (let ((confirm confirm-kill-emacs)) (and (or (not (memq t (mapcar (lambda (buf) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 48b5ee9973..d3d3849c83 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -790,7 +790,10 @@ compilation-save-buffers-predicate (string-prefix-p my-compilation-root (file-truename (buffer-file-name)))) to limit saving to files located under `my-compilation-root'. Note, that, in general, `compilation-directory' cannot be used instead -of `my-compilation-root' here." +of `my-compilation-root' here. + +See `save-some-buffers-restrict-to-caller-subdirs' for a consistent +way to achieve this." :type '(choice (const :tag "Default (save all file-visiting buffers)" nil) (const :tag "Save all buffers" t) diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index d6ee8bb423..5454d47211 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -246,7 +246,11 @@ grep-save-buffers buffer should be saved or not. E.g., one can set this to (lambda () (string-prefix-p my-grep-root (file-truename (buffer-file-name)))) -to limit saving to files located under `my-grep-root'." +to limit saving to files located under `my-grep-root'. + +Note that `my-grep-root' is only known at runtime. See +`save-some-buffers-restrict-to-caller-subdirs' for a consistent way to +achieve the same goal." :version "26.1" :type '(choice (const :tag "Ask before saving" ask) diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 149cc689ae..14d6bc099d 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -1432,5 +1432,206 @@ files-tests-revert-buffer-with-fine-grain (buffer-substring (point-min) (point-max)) nil nil))))) -(provide 'files-tests) +(defun files-tests--save-some-buffers (pred caller-subdirs-only exp-1 exp-2) + "Helper function to test `save-some-buffers'. + +This function creates two visiting-file buffers, BUF-1, BUF-2 in + different directories at the same level, i.e., none of them is a + subdir of the other; then, it modifies both buffers; finally it calls + `save-some-buffers' from BUF-1 with first arg t and second arg PRED + and `save-some-buffers-restrict-to-caller-subdirs' let-bound to + CALLER-SUBDIRS-ONLY. + +EXP-1 and EXP-1 are the expected values of the modified flags of BUF-1 +and BUF-2 after the `save-some-buffers' call. + +The test is repeated with `save-some-buffers-default-predicate' +let-bound to PRED and passing nil as second arg of +`save-some-buffers'." + (let* ((dir (make-temp-file "testdir" 'dir)) + (file-1 (expand-file-name "subdir-1/file.foo" dir)) + (file-2 (expand-file-name "subdir-2/file.bar" dir)) + (inhibit-message t) + buf-1 buf-2) + (unwind-protect + (progn + (make-empty-file file-1 'parens) + (make-empty-file file-2 'parens) + (setq buf-1 (find-file file-1) + buf-2 (find-file file-2)) + (dolist (buf (list buf-1 buf-2)) + (with-current-buffer buf (insert "foobar\n"))) + ;; buf-2 is ignored if `save-some-buffers-restrict-to-caller-subdirs' is non-nil. + (with-current-buffer buf-1 + (let ((save-some-buffers-restrict-to-caller-subdirs caller-subdirs-only)) + (save-some-buffers t pred)) + (should (eq exp-1 (buffer-modified-p buf-1))) + (should (eq exp-2 (buffer-modified-p buf-2)))) + + ;; Set both buffers as modified to repeat the test. + (dolist (buf (list buf-1 buf-2)) + (with-current-buffer buf (set-buffer-modified-p t))) + ;; Same result with: `save-some-buffers-default-predicate' -> pred, pred -> nil. + (with-current-buffer buf-1 + (let ((save-some-buffers-restrict-to-caller-subdirs caller-subdirs-only) + (save-some-buffers-default-predicate (and (functionp pred) pred))) + (save-some-buffers t nil)) + (should (eq exp-1 (buffer-modified-p buf-1))) + (should (eq exp-2 (buffer-modified-p buf-2))))) + ;; Clean up. + (dolist (buf (list buf-1 buf-2)) + (with-current-buffer buf + (set-buffer-modified-p nil) + (kill-buffer buf))) + (delete-directory dir 'recursive)))) + +(ert-deftest files-tests-save-some-buffers () + "Test `save-some-buffers'. +Test the 3 cases for the second argument PRED, i.e., `nil', `t' or +predicate." + (let* ((foo-file-p (lambda () (string-suffix-p ".foo" buffer-file-name))) + (bar-file-p (lambda () (string-suffix-p ".bar" buffer-file-name))) + (args-results `((nil nil nil nil) + (nil t nil t) + (,foo-file-p nil nil t) + (,bar-file-p nil t nil) + (,foo-file-p t nil t) + (,bar-file-p t t t) + (t nil nil nil) + (t t nil t)))) + (pcase-dolist (`(,pred ,caller-subdirs-only ,exp-1 ,exp-2) args-results) + (files-tests--save-some-buffers pred caller-subdirs-only exp-1 exp-2)))) + +(defmacro files-tests--with-buffer-offer-save (buffers-offer fn-test fn-binders args-results) + "Helper macro to test `save-some-buffers' and `save-buffers-kill-emacs'. + +This macro creates several non-visiting-file buffers in different + directories at the same level, i.e., none of them is a subdir of the + other; then, it modifies the buffers and sets `buffer-offer-save' per + each buffer as specified by BUFFERS-OFFER, a list of elements + (BUFFER OFFER-SAVE). Finally it calls FN-TEST from the first + buffer. + +FN-TEST is the function to test: either `save-some-buffers' or +`save-buffers-kill-emacs'. This function is called with +`save-some-buffers-restrict-to-caller-subdirs' let-bound to a value +specified inside ARGS-RESULTS. + +FN-BINDERS is a list of elements (FUNCTION . BINDING), where FUNCTION +is a function symbol that this macro temporary binds to BINDING during +the FN-TEST call. +ARGS-RESULTS is a list of elements (FN-ARGS CALLERS-DIR RESULTS), where + FN-ARGS are the arguments for FN-TEST; + CALLERS-DIR specify the value to let-bind +`save-some-buffers-restrict-to-caller-subdirs'; + RESULTS are the expected results of the test." + (declare (debug (form symbol form form))) + (let ((dir (gensym "dir")) + (buffers (gensym "buffers"))) + `(let* ((,dir (make-temp-file "testdir" 'dir)) + (inhibit-message t) + (use-dialog-box nil) + ,buffers) + (pcase-dolist (`(,bufsym ,offer-save) ,buffers-offer) + (let* ((buf (generate-new-buffer (symbol-name bufsym))) + (subdir (expand-file-name + (format "subdir-%s" (buffer-name buf)) + ,dir))) + (make-directory subdir 'parens) + (push buf ,buffers) + (with-current-buffer buf + (cd subdir) + (setq buffer-offer-save offer-save) + (insert "foobar\n")))) + (setq ,buffers (nreverse ,buffers)) + + (let ((nb-saved-buffers 0)) + (unwind-protect + (pcase-dolist (`(,fn-test-args ,callers-dir ,expected) + ,args-results) + (setq nb-saved-buffers 0) + (with-current-buffer (car ,buffers) + (cl-letf + (,@(mapcar (lambda (pair) `((symbol-function ,(car pair)) ,(cdr pair))) + fn-binders) + (save-some-buffers-restrict-to-caller-subdirs callers-dir)) + (apply #',fn-test fn-test-args) + (should (equal nb-saved-buffers expected))))) + ;; Clean up. + (dolist (buf ,buffers) + (with-current-buffer buf + (set-buffer-modified-p nil) + (kill-buffer buf))) + (delete-directory ,dir 'recursive)))))) + +(defmacro files-tests-with-all-permutations (permutation list &rest body) + "Execute BODY forms for all permutation of LIST. +Execute the forms with the symbol PERMUTATION bound to the current +permutation." + (declare (indent 2) (debug (symbol form body))) + (let ((vec (gensym "vec"))) + `(let ((,vec (vconcat ,list))) + (cl-labels ((swap (,vec i j) + (let ((tmp (aref ,vec j))) + (aset ,vec j (aref ,vec i)) + (aset ,vec i tmp))) + (permute (,vec l r) + (if (= l r) + (let ((,permutation (append ,vec nil))) + ,@body) + (cl-loop for idx from l below (1+ r) do + (swap ,vec idx l) + (permute ,vec (1+ l) r) + (swap ,vec idx l))))) + (permute ,vec 0 (1- (length ,vec))))))) + +(ert-deftest files-tests-buffer-offer-save () + "Test `save-some-buffers'. +Check the expected behavior for non-visiting-file buffers with +a non-nil value of `buffer-offer-save'." + (let* ((buffers-offer-init '((buf-1 t) (buf-2 always) (buf-3 nil))) + (nb-might-save + (length + (cl-remove-if (lambda (l) (null (cadr l))) buffers-offer-init))) + (nb-always-save + (length + (cl-remove-if-not (lambda (l) (eq 'always (cadr l))) buffers-offer-init)))) + (files-tests-with-all-permutations + buffers-offer + buffers-offer-init + (dolist (must-save `(nil t)) + (dolist (callers-dir `(nil t)) + (let* ((head-offer (cadar buffers-offer)) + (res (if must-save + (if callers-dir (or (and head-offer 1) 0) + nb-might-save) + (if callers-dir (or (and (eq 'always head-offer) 1) 0) + nb-always-save))) + (args-res `(((nil ,must-save) ,callers-dir ,res)))) + (files-tests--with-buffer-offer-save + buffers-offer + save-some-buffers + ;; Increase counter and answer 'n' when prompted to save a buffer. + (('read-event . (lambda () (cl-incf nb-saved-buffers) ?n))) + args-res))))))) + +(ert-deftest files-tests-save-buffers-kill-emacs--asks-to-save-buffers () + "Test that `save-buffers-kill-emacs' asks to save buffers as expected." + (let* ((buffers-offer-init '((buf-1 t) (buf-2 always) (buf-3 nil))) + (nb-might-save + (length + (cl-remove-if (lambda (l) (null (cadr l))) buffers-offer-init)))) + (files-tests-with-all-permutations + buffers-offer + buffers-offer-init + ;; Order doesn't matter: ask to save any buffer with non-nil `buffer-offer-save'. + (files-tests--with-buffer-offer-save + buffers-offer + save-buffers-kill-emacs + ;; Increase counter and answer 'n' when prompted to save a buffer. + (('read-event . (lambda () (cl-incf nb-saved-buffers) ?n)) + ('kill-emacs . #'ignore)) ; Do not kill Emacs. + `((nil nil ,nb-might-save) (nil t ,nb-might-save)))))) + + ;;; files-tests.el ends here --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 28.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars) of 2021-02-07 built on localhost.example.com Repository revision: 7c5938ad7d8884d03471e2395937e11611faadb9 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12010000 System Description: openSUSE Tumbleweed Configured using: 'configure --with-x-toolkit=lucid' Configured features: CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM LUCID ZLIB Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs rfc822 mml easymenu mml-sec epa derived epg epg-config gnus-util rmail rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map text-property-search time-date subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 52136 5739) (symbols 48 6583 1) (strings 32 19227 1884) (string-bytes 1 625859) (vectors 16 12486) (vector-slots 8 169553 9399) (floats 8 23 41) (intervals 56 211 0) (buffers 984 10)) From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 08 10:07:12 2021 Received: (at 46374) by debbugs.gnu.org; 8 Feb 2021 15:07:12 +0000 Received: from localhost ([127.0.0.1]:51669 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9887-0001cp-W6 for submit@debbugs.gnu.org; Mon, 08 Feb 2021 10:07:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47674) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9886-0001cd-Iy for 46374@debbugs.gnu.org; Mon, 08 Feb 2021 10:07:10 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51543) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l987z-0004gC-LM; Mon, 08 Feb 2021 10:07:05 -0500 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4480 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l987q-000372-CI; Mon, 08 Feb 2021 10:06:58 -0500 Date: Mon, 08 Feb 2021 17:07:09 +0200 Message-Id: <83lfbylhsy.fsf@gnu.org> From: Eli Zaretskii To: Tino Calancha In-Reply-To: <878s7z4ihk.fsf@gmail.com> (message from Tino Calancha on Sun, 07 Feb 2021 23:32:07 +0100) Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir References: <878s7z4ihk.fsf@gmail.com> X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, monnier@iro.umontreal.ca, uyennhi.qm@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > From: Tino Calancha > Date: Sun, 07 Feb 2021 23:32:07 +0100 > Cc: stefan monnier , uyennhi.qm@gmail.com > > > I wish, by default, to only been prompted for buffers whose default-directory > is under the caller dir (except when closing Emacs). > > ## Description > Everyday I connect via Tramp with machines at each of my properties (Hawaii, > Maldives, Palawan, and a very large etc.) > Then, in the same Emacs session, I connect to a host in Wall Street to see > how my stock grows, making me richer. > Often, a compilation buffer at New York city prompts me to save a buffer > at Waikiki beach. Quite distracting! Cannot focus on my money! > > I found some people with related issues: > https://emacs.stackexchange.com/questions/7268/package-el-asks-whether-i-want-to-save-modified-files-before-package-installatio > https://emacs.stackexchange.com/questions/40593/automatically-dont-save-buffers-before-compiling > > ## How to reproduce > Sure, I understand not all of you can possibly reproduce the above conditions. > Maybe you can try the following poor man's recipe: > > emacs -Q ~/foo.txt > ;; write something and do not save > foo > ;; now visit another, for instance, the Emacs source dir > C-x d EMACS-SRC-DIR RET > ;; call rgrep with whatever string > M-x rgrep money RET *.el RET RET > ;; You will be prompted to save ~/foo.txt You are assuming that when save-some-buffers runs, the default directory is the same as when you issued whatever command triggered the call to save-some-buffers? Is that assumption really accurate? From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 08 10:47:26 2021 Received: (at 46374) by debbugs.gnu.org; 8 Feb 2021 15:47:26 +0000 Received: from localhost ([127.0.0.1]:51729 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l98l4-0002eZ-DP for submit@debbugs.gnu.org; Mon, 08 Feb 2021 10:47:26 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:39251) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l98l1-0002eJ-US for 46374@debbugs.gnu.org; Mon, 08 Feb 2021 10:47:25 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 18D9F8090A; Mon, 8 Feb 2021 10:47:18 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C1BAC8063A; Mon, 8 Feb 2021 10:47:16 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1612799236; bh=FUi914u5eCoiMRd//cigeVKuXPjdUpUuvypIkYtCfxc=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=gw6KyQBR04QdkUM8Y9XGfYHrYVHqvaCe/+AduOWMwr8Z/mXTp0pRISfsetbS6JOsG vyZ+LOBGSkpRwpIj8AYQTzqI+H4ewJqWaVbkXAiyAt/rN6YeR91199v82rsgyR0dMM YkXsEmvDHNzASe2dsf/HMBBODeefIbBN7CNmZn3rXAzMPBsTrpYVeUNiQDb86SuOJM 3nf8wId+rnT5JX9TTZztrliHAzG9qruMGVHXHCKVfyiB9/m0LOtw6YquTIdSHNMqDB /5mFK/LiijGVN23lO9d+CuemLhkeQ+Zvzkjtl9mrScVhB6Eg3P694UcJ1JwSHWELmT ay2m3VnSd8hCw== Received: from alfajor (unknown [216.154.41.47]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 90FD7120155; Mon, 8 Feb 2021 10:47:16 -0500 (EST) From: Stefan Monnier To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Message-ID: References: <878s7z4ihk.fsf@gmail.com> Date: Mon, 08 Feb 2021 10:47:15 -0500 In-Reply-To: <878s7z4ihk.fsf@gmail.com> (Tino Calancha's message of "Sun, 07 Feb 2021 23:32:07 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.081 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, uyennhi.qm@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > I wish, by default, to only been prompted for buffers whose default-directory > is under the caller dir (except when closing Emacs). If we want to have such a behavior and make it optional, it's fine by me. But if we want to make it a default behavior, then I think `project-root` would be much a much better choice (when available) than `default-directory`. Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 09 13:15:23 2021 Received: (at 46374) by debbugs.gnu.org; 9 Feb 2021 18:15:23 +0000 Received: from localhost ([127.0.0.1]:54542 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9XXm-0007Z3-T5 for submit@debbugs.gnu.org; Tue, 09 Feb 2021 13:15:23 -0500 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:41939) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9XXk-0007Yl-Qg for 46374@debbugs.gnu.org; Tue, 09 Feb 2021 13:15:21 -0500 X-Originating-IP: 91.129.108.204 Received: from mail.gandi.net (m91-129-108-204.cust.tele2.ee [91.129.108.204]) (Authenticated sender: juri@linkov.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 341F41BF207; Tue, 9 Feb 2021 18:15:11 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> Date: Tue, 09 Feb 2021 19:50:33 +0200 In-Reply-To: <878s7z4ihk.fsf@gmail.com> (Tino Calancha's message of "Sun, 07 Feb 2021 23:32:07 +0100") Message-ID: <87a6sdzeh6.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, stefan monnier , uyennhi.qm@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > @vindex save-some-buffers-default-predicate > +@vindex save-some-buffers-restrict-to-caller-subdirs > You can customize the value of > -@code{save-some-buffers-default-predicate} to control which buffers > -Emacs will ask about. > +@code{save-some-buffers-default-predicate} and > +@code{save-some-buffers-restrict-to-caller-subdirs} to control which > +buffers Emacs will ask about. Why not simply add a new option to the existing variable save-some-buffers-default-predicate? For example: (defcustom save-some-buffers-default-predicate nil "Default predicate for `save-some-buffers'." :group 'auto-save ;; 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) (const :tag "Subdirs of default directory" default-directory) (const :tag "Project root" project-root) function) From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 07 15:34:25 2021 Received: (at 46374) by debbugs.gnu.org; 7 Mar 2021 20:34:25 +0000 Received: from localhost ([127.0.0.1]:41605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJ06a-00085p-TL for submit@debbugs.gnu.org; Sun, 07 Mar 2021 15:34:25 -0500 Received: from mail-wm1-f54.google.com ([209.85.128.54]:43603) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJ06W-00085a-Pj for 46374@debbugs.gnu.org; Sun, 07 Mar 2021 15:34:22 -0500 Received: by mail-wm1-f54.google.com with SMTP id a25-20020a1cf0190000b029010b1cbe2dd0so2522216wmb.2 for <46374@debbugs.gnu.org>; Sun, 07 Mar 2021 12:34:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=u6IO9fCrjGg+BI2P3wa2HLiuIqJTO7agS6gEA9BNKfg=; b=tmDiYN+smgf/scyMDU3p+s8m8bzpE6R/qCrSttuF2cQhH7SxtIZPsT38buAO1SVxub 1eoikMK5k1lwlfTfKyHONqG/DlHZXmZaQoSC2E1LhuqxLaCHKLe711mZTcXhcfjPmMWS MTzNOwhSgTDxeyw/jKMX9ISaDsvaYpVZspBZfwAyBH3iDOP+BwOXN7+/5MnS+PffjTLV oUxHosSK9Tm/H8D1dl/9KqbUNcdaEPa6d1+WsZNFNG1yVGJLBMVwuSNiWOmoAQ3U2pkK mlkwBlX7JCaxgiuMRQG0T2GfZPoyb1iHUWGbnjPX59n18FLPkGTb453Ynx6gwIJCynkR sGmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=u6IO9fCrjGg+BI2P3wa2HLiuIqJTO7agS6gEA9BNKfg=; b=sQedp6ZweesIxUVx/vfb2yz/JD5AK75l9w7YvVBxlofR4yCrW7K53sDunlyuS/Yft5 WcIyiwZzcT68+Ory25USukvjsViNKhD9yuf8XPbDE+pphmyMAwtw5bgdEMU/9KM1sz1s cN0aSqdol6pjcXhTLKOarK6vozezruxViUA6KxmINY2BTNMxEUjjFWxZshvwEDQ8RUhn GD61rtac/xWFmyDt5YRMSd1uK33AZT8T4MoU4yi+WnFckivMWtzRSXd3vR+CZDtkeWz+ JMhEcmaHDOfrr04P1nAzQcViyJqCoCjMbIvN1xj7brc0wbjk/IO7Tw04nvlm0IWtVYCi CAmQ== X-Gm-Message-State: AOAM532fDIMMkHqeYMP5amtqO52Z9TLkRlH/2ORWoqXDoYJuaq7B2Htb igkMCQqKdm7kes/xxJo8YFA= X-Google-Smtp-Source: ABdhPJw44qY9GZDjCdB0vkCNTYPsoQUcQFBqnd4Mjio0AYKdFV5DXMCLlcQLk0FH4tlVBfIbIj5dFg== X-Received: by 2002:a05:600c:c4:: with SMTP id u4mr19282344wmm.27.1615149254868; Sun, 07 Mar 2021 12:34:14 -0800 (PST) Received: from localhost.example.com ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id a75sm15547030wme.10.2021.03.07.12.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Mar 2021 12:34:14 -0800 (PST) From: Tino Calancha To: Juri Linkov Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> Date: Sun, 07 Mar 2021 21:34:13 +0100 In-Reply-To: <87a6sdzeh6.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 09 Feb 2021 19:50:33 +0200") Message-ID: <87ft16g0u2.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, stefan monnier , uyennhi.qm@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Sorry for the late response: many meetings with investors. Then I went on a vacation to my castle in Seychelles. Eli Zaretskii writes: >> You are assuming that when save-some-buffers runs, the default >> directory is the same as when you issued whatever command triggered >> the call to save-some-buffers? Is that assumption really accurate? I don't know if there are some corner cases. In my experience, I am hit by this (very often) when using packages that call `compilation-start`. Prominent examples are `rgrep` or when downloading ELPA updates (they will trigger a compilation as well). The patch is serving me very well so far. Juri Linkov writes: >> @vindex save-some-buffers-default-predicategn >> +@vindex save-some-buffers-restrict-to-caller-subdirs >> You can customize the value of >> -@code{save-some-buffers-default-predicate} to control which buffers >> -Emacs will ask about. >> +@code{save-some-buffers-default-predicate} and >> +@code{save-some-buffers-restrict-to-caller-subdirs} to control which >> +buffers Emacs will ask about. > > Why not simply add a new option to the existing variable > save-some-buffers-default-predicate? For example: > > (defcustom save-some-buffers-default-predicate nil > "Default predicate for `save-some-buffers'." > :group 'auto-save > ;; 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) > (const :tag "Subdirs of default directory" default-directory) > (const :tag "Project root" project-root) > function) Indeed, this was my initial implemention. Then I moved to the one I shared here; I found my second version superior for the following reason: 1. Users can restrict the buffer default directory AND still pass a predicate to filter by any other thing they wish; i.e. you don't need to chose either one of the other. 2. I find it cleaner having it in a separated option. Stefan Monnier >> If we want to have such a behavior and make it optional, it's fine by me. It's optional in my patch; some people might like the current situation: been prompted about any modified buffer. >> But if we want to make it a default behavior, then I think >> `project-root` would be much a much better choice (when available) than >> `default-directory`. Would this `project-root` feature work for `rgrep`? I mean, I can call `rgrep` in my local computer, out of any project, for instance to search for information in some plain text notes. In this case, `default-directory` works quite well. From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 07 16:11:02 2021 Received: (at 46374) by debbugs.gnu.org; 7 Mar 2021 21:11:02 +0000 Received: from localhost ([127.0.0.1]:41626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJ0g2-0000WW-2T for submit@debbugs.gnu.org; Sun, 07 Mar 2021 16:11:02 -0500 Received: from relay10.mail.gandi.net ([217.70.178.230]:55845) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJ0fz-0000W2-Nn for 46374@debbugs.gnu.org; Sun, 07 Mar 2021 16:11:01 -0500 Received: from mail.gandi.net (m91-129-108-46.cust.tele2.ee [91.129.108.46]) (Authenticated sender: juri@linkov.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 7DBFC240005; Sun, 7 Mar 2021 21:10:51 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> Date: Sun, 07 Mar 2021 23:08:02 +0200 In-Reply-To: <87ft16g0u2.fsf@gmail.com> (Tino Calancha's message of "Sun, 07 Mar 2021 21:34:13 +0100") Message-ID: <87tupmisel.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, stefan monnier , uyennhi.qm@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > Sorry for the late response: many meetings with investors. > Then I went on a vacation to my castle in Seychelles. Oh, I thought you were busy running for President. >> Why not simply add a new option to the existing variable >> save-some-buffers-default-predicate? For example: >> >> (defcustom save-some-buffers-default-predicate nil >> "Default predicate for `save-some-buffers'." >> :group 'auto-save >> ;; 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) >> (const :tag "Subdirs of default directory" default-directory) >> (const :tag "Project root" project-root) >> function) > > Indeed, this was my initial implemention. > Then I moved to the one I shared here; I found my second version > superior for the following reason: > > 1. Users can restrict the buffer default directory AND still pass a > predicate to filter by any other thing they wish; > i.e. you don't need to chose either one of the other. > > 2. I find it cleaner having it in a separated option. I'm not sure if there is a need for adding another dimension with another option. But if yes, then still shouldn't a new option provide a wider choice of restricting predicates like above? From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 08 12:36:02 2021 Received: (at 46374) by debbugs.gnu.org; 8 Mar 2021 17:36:03 +0000 Received: from localhost ([127.0.0.1]:44687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJJnW-000249-Co for submit@debbugs.gnu.org; Mon, 08 Mar 2021 12:36:02 -0500 Received: from relay13.mail.gandi.net ([217.70.178.233]:50287) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJJnT-00023c-II for 46374@debbugs.gnu.org; Mon, 08 Mar 2021 12:36:00 -0500 Received: from mail.gandi.net (m91-129-108-46.cust.tele2.ee [91.129.108.46]) (Authenticated sender: juri@linkov.net) by relay13.mail.gandi.net (Postfix) with ESMTPSA id 59B4A8000D; Mon, 8 Mar 2021 17:35:51 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> Date: Mon, 08 Mar 2021 19:28:00 +0200 In-Reply-To: <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> (Tino Calancha's message of "Sun, 7 Mar 2021 22:31:47 +0100 (CET)") Message-ID: <87r1kpemnr.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, stefan monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >>>> Why not simply add a new option to the existing variable >>>> save-some-buffers-default-predicate? For example: >>>> >>>> (defcustom save-some-buffers-default-predicate nil >>>> "Default predicate for `save-some-buffers'." >>>> :group 'auto-save >>>> ;; 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) >>>> (const :tag "Subdirs of default directory" default-directory) >>>> (const :tag "Project root" project-root) >>>> function) >>> >>> Indeed, this was my initial implemention. >>> Then I moved to the one I shared here; I found my second version >>> superior for the following reason: >>> >>> 1. Users can restrict the buffer default directory AND still pass a >>> predicate to filter by any other thing they wish; >>> i.e. you don't need to chose either one of the other. >>> >>> 2. I find it cleaner having it in a separated option. >> >> I'm not sure if there is a need for adding >> another dimension with another option. > > This is explained in my point 1. above. > I might want to restrict to the caller subdir and still filter with > a function. You cannot get both things just with one option. > > For my normal worflow, this is a very important addition and I am looking > forward to see it added in master soon. Please consider the consequences of backward-incompatibility of adding such a separate option. For example, in the org package: org-mobile-push: (save-some-buffers nil (lambda () (memq (current-buffer) agenda-buffers))) When a user customizes a new option to restrict saving of buffers to the subdirectories only, this means it will skip saving agenda-buffers since most of them usually are located outside of the current directory. This change would have a drastic effect for external packages where a new option can't be forced to be bound to nil. More examples: org-save-all-org-buffers: (save-some-buffers t (lambda () (derived-mode-p 'org-mode))) etc. This means reusing the existing save-some-buffers-default-predicate would be still preferable that guarantees backward-compatibility. When it's customized to a predicate to filter out non-current subdirs, then such call '(save-some-buffers t (lambda () (derived-mode-p 'org-mode)))' still overrides the customized value. This is the right thing to do. >> But if yes, then still shouldn't a new option >> provide a wider choice of restricting predicates >> like above? > > Yeah, we could made wider the new option as you've suggested: >>>> (const :tag "Subdirs of default directory" default-directory) >>>> (const :tag "Project root" project-root) > > Since Stefan mentioned `project-root` is not ready and I am not familiar > with it, I suggest we add the option as it is, possibly with a modified > name that fit well our future intention and a TODO comment. > Then, me or someone else, can update the option when `project-root` > become mature. > > Agreed? Then the option could be named 'project-root-or-subdirs', so when a command is called outside a project, it will fall back to subdirs. From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 14 08:17:14 2021 Received: (at 46374) by debbugs.gnu.org; 14 Mar 2021 12:17:14 +0000 Received: from localhost ([127.0.0.1]:33052 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLPgI-0002zg-AV for submit@debbugs.gnu.org; Sun, 14 Mar 2021 08:17:14 -0400 Received: from mail-ed1-f45.google.com ([209.85.208.45]:37550) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLPgH-0002zU-1S for 46374@debbugs.gnu.org; Sun, 14 Mar 2021 08:17:13 -0400 Received: by mail-ed1-f45.google.com with SMTP id x21so14036042eds.4 for <46374@debbugs.gnu.org>; Sun, 14 Mar 2021 05:17:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=anMgpLTNd3NtfHCE6CQjqz8mDhipIV/KMRrb/36lDL0=; b=Z2GjPBuYS2MoFcxiBD1OwPISY+R06LYZJdxUhRhfajU71VYCJAuGzZPSKTs/umhtoF vjOvQOXKvxSEtmO5pi6ox2lNcAKbCLF/Hz5pzXZ82SWY0UPVDw36PbeImGproe/Bzfgs COZjWahNrkLED2wRVy5gFlImgGTNlWav14/tkKwwN/WY5IkckDIeTzgJTRdStB+pX6+u k90Tb3eaH16J34p06/kQlif9rlJp8N54swmm7QsLpOsTope0HFwZdJY6nrn/d7ZkQQjE D7ASAz0pxRf6oWOIiXmkiq4szhIQ4HYft9+aTH1waCRhBo2mXXmtqDGvgY+tTfngA4sl JsrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=anMgpLTNd3NtfHCE6CQjqz8mDhipIV/KMRrb/36lDL0=; b=lgBABd6SoOLVLJyTdt+Hbm7a1sp0dO1vaWCAyz8Y4lwhttXkinVVoWGFEfg8HWb1j3 4cPUaOAbDVguvKJCqXr0BOkKP275AonRvrzZPUlG+QE0rmLORhxm3FoKbKWq2GoF1W/w 8qRyFkxEnc4kah0XgQCQTtzTbMni6po7snPhTKMBrWi5qkBYfdrLlcPQlYpySXsy6UJQ T2ZCg4NPh0D7UsN6of33UH1Yj6diL/hcNKvaIwA8qOfkro4mbIvQRCDPmToARaidDMOR o0jrifuNFzKaBxRsrLhK+5AZDhM6PmCkEEmsgh1dW0AaJ8KYsXJPcpWjHFSxdO8bQd8z AXtg== X-Gm-Message-State: AOAM530mdsG1j2rWFxIPWjlRlPGDwwfzsDcQD88We2IHPutjUSHlaOe/ PMhwauQ9mLQ+BpU68ChVJdk= X-Google-Smtp-Source: ABdhPJyHHdiPzSj6wAgRnv5nZXCFKiC9yLzxMG4cpQ1y6YASZ3/L2qnrNU1dlBwYN3J/cM0d0H3hoQ== X-Received: by 2002:a05:6402:646:: with SMTP id u6mr25142198edx.250.1615724227219; Sun, 14 Mar 2021 05:17:07 -0700 (PDT) Received: from localhost.example.com ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id 90sm6615814edr.69.2021.03.14.05.17.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Mar 2021 05:17:06 -0700 (PDT) From: Tino Calancha To: Juri Linkov Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> Date: Sun, 14 Mar 2021 13:17:05 +0100 In-Reply-To: <87r1kpemnr.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 08 Mar 2021 19:28:00 +0200") Message-ID: <87mtv6yloe.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, stefan monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Juri Linkov writes: > This means reusing the existing save-some-buffers-default-predicate > would be still preferable that guarantees backward-compatibility. > When it's customized to a predicate to filter out non-current subdirs, > then such call '(save-some-buffers t (lambda () (derived-mode-p 'org-mode)))' > still overrides the customized value. This is the right thing to do. OK, back to my original implementation (i.e., adding a new option to `save-some-buffers-default-predicate`). I have been playing with the followig patch this morning. - it only adds a new option 'project-root - in case there is not a root there, then `default-directory` is taken (this is a requirement from the OP, that ie me :-) - this patch doesn't interfere with the 2nd argument of `save-some-buffers'. Please, try it: --8<-----------------------------cut here---------------start------------->8--- diff --git a/lisp/files.el b/lisp/files.el index dada69c145..d890e5b7b7 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5517,7 +5517,9 @@ save-some-buffers-default-predicate :group 'auto-save ;; 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) + :type '(choice (const :tag "Default" nil) + (const :tag "Project root" project-root) + function) :version "26.1") (defun save-some-buffers (&optional arg pred) @@ -5546,9 +5548,22 @@ save-some-buffers 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)) - (let* ((switched-buffer nil) + (let* ((project-dir (or (and (project-current) (project-root (project-current))) + default-directory)) + (effective-pred + (or pred + (if (eq 'project-root save-some-buffers-default-predicate) + (lambda () (file-in-directory-p default-directory project-dir)) + save-some-buffers-default-predicate))) + (switched-buffer nil) + (non-visiting-buffers-ok (not (null pred))) + (buffer-name-matches-filename-p + (lambda (buffer) + "Return non-nil if BUFFER name is similar to its file name." + (let ((file-basename (file-name-nondirectory (buffer-file-name buffer)))) + (or (equal (buffer-name buffer) file-basename) + (string-match-p (format "\\<%s<[^>]*>\\'" (regexp-quote file-basename)) + (buffer-name buffer)))))) (save-some-buffers--switch-window-callback (lambda (buffer) (setq switched-buffer buffer))) @@ -5578,36 +5593,19 @@ save-some-buffers (buffer-file-name buffer) (with-current-buffer buffer (or (eq buffer-offer-save 'always) - (and pred buffer-offer-save - (> (buffer-size) 0))))) - (or (not (functionp pred)) - (with-current-buffer buffer (funcall pred))) + (and non-visiting-buffers-ok buffer-offer-save (> (buffer-size) 0))))) + (or (not (functionp effective-pred)) + (with-current-buffer buffer (funcall effective-pred))) (if arg t (setq queried t) - (if (buffer-file-name buffer) - (if (or - (equal (buffer-name buffer) - (file-name-nondirectory - (buffer-file-name buffer))) - (string-match - (concat "\\<" - (regexp-quote - (file-name-nondirectory - (buffer-file-name buffer))) - "<[^>]*>\\'") - (buffer-name buffer))) - ;; The buffer name is similar to the - ;; file name. - (format "Save file %s? " - (buffer-file-name buffer)) - ;; The buffer and file names are - ;; dissimilar; display both. - (format "Save file %s (buffer %s)? " - (buffer-file-name buffer) - (buffer-name buffer))) - ;; No file name - (format "Save buffer %s? " (buffer-name buffer)))))) + (cond ((null (buffer-file-name buffer)) + (format "Save buffer %s? " (buffer-name buffer))) + ((funcall buffer-name-matches-filename-p buffer) + (format "Save file %s? " (buffer-file-name buffer))) + (t (format "Save file %s (buffer %s)? " + (buffer-file-name buffer) + (buffer-name buffer))))))) (lambda (buffer) (with-current-buffer buffer (save-buffer))) --8<-----------------------------cut here---------------end--------------->8--- From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 15 13:11:00 2021 Received: (at 46374) by debbugs.gnu.org; 15 Mar 2021 17:11:00 +0000 Received: from localhost ([127.0.0.1]:36671 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLqk8-0000rf-0a for submit@debbugs.gnu.org; Mon, 15 Mar 2021 13:11:00 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:35897) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLqk3-0000qp-Bc for 46374@debbugs.gnu.org; Mon, 15 Mar 2021 13:10:55 -0400 X-Originating-IP: 91.129.108.46 Received: from mail.gandi.net (m91-129-108-46.cust.tele2.ee [91.129.108.46]) (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id ACA8DFF809; Mon, 15 Mar 2021 17:10:47 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> Date: Mon, 15 Mar 2021 19:10:02 +0200 In-Reply-To: <87mtv6yloe.fsf@gmail.com> (Tino Calancha's message of "Sun, 14 Mar 2021 13:17:05 +0100") Message-ID: <871rcgr4qp.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> This means reusing the existing save-some-buffers-default-predicate >> would be still preferable that guarantees backward-compatibility. >> When it's customized to a predicate to filter out non-current subdirs, >> then such call '(save-some-buffers t (lambda () (derived-mode-p 'org-mode)))' >> still overrides the customized value. This is the right thing to do. > > OK, back to my original implementation (i.e., adding a new option > to `save-some-buffers-default-predicate`). > > I have been playing with the followig patch this morning. > - it only adds a new option 'project-root > - in case there is not a root there, then `default-directory` is taken > (this is a requirement from the OP, that ie me :-) > - this patch doesn't interfere with the 2nd argument of `save-some-buffers'. > > Please, try it: Thanks, I tried it. The only problem is that the value 'project-root' is hard-coded. Would it be possible to create a real function from it? This will require giving a proper prefix to it, indeed, such as e.g. 'save-some-buffers-project-root'. But this will allow greater customization. For example, everyone could copy its default implementation to the init file and modify its logic to check separately project-root from subdirs, etc. Also it will remove unnecessary details of getting the project root from the implementation of 'save-some-buffers', and to avoid the need to preload project.el. 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. From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 16 13:58:49 2021 Received: (at 46374) by debbugs.gnu.org; 16 Mar 2021 17:58:49 +0000 Received: from localhost ([127.0.0.1]:40973 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMDxx-0005P6-Bx for submit@debbugs.gnu.org; Tue, 16 Mar 2021 13:58:49 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:33055) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMDxt-0005Oe-BR for 46374@debbugs.gnu.org; Tue, 16 Mar 2021 13:58:48 -0400 X-Originating-IP: 91.129.107.223 Received: from mail.gandi.net (m91-129-107-223.cust.tele2.ee [91.129.107.223]) (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id C94A8E0004; Tue, 16 Mar 2021 17:58:36 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> Date: Tue, 16 Mar 2021 19:49:27 +0200 In-Reply-To: <871rcgr4qp.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 15 Mar 2021 19:10:02 +0200") Message-ID: <87zgz3gfqo.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> 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) From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 16 18:54:25 2021 Received: (at 46374) by debbugs.gnu.org; 16 Mar 2021 22:54:25 +0000 Received: from localhost ([127.0.0.1]:41410 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMIa1-0006Ei-4c for submit@debbugs.gnu.org; Tue, 16 Mar 2021 18:54:25 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:28911) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMIZw-0006ES-NC for 46374@debbugs.gnu.org; Tue, 16 Mar 2021 18:54:24 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 027284410A4; Tue, 16 Mar 2021 18:54:15 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id AFC6344108B; Tue, 16 Mar 2021 18:54:13 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1615935253; bh=isH07Jq6aXvqIEcPOTSCv5KFGIgDKPQjcXj/vkL8wvc=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Y6R2DFNbI+97EuQQ23mJoVrQI+lM1mRuN/Y7nwEB5DlMuUk4Ck4FYS/uv6VvPbcHN SaApAeP5Q/97OZfw9dzzQ3U9ZybJLOpWUmQnLHrYJ9EyoFn+ii5WTDeDaWLnkfTgmz PiRFJqPVyWvhWpZQKeyCRMXYrFhxd0ZwXqkKNH/d6KKt6vbhK5PBi1+heVEh3JTwWX prPL5iEL5ReHD/6O1jhw+Ssi4ZBQO0gdfbzyv2E+Xej0fEcOhi1wQTZUyAkUyNjbBs wbfF0fz6/IwSRgS/Ilgm9Le7vCZ4MUe/g1AAHznbnqGgElfcsE20e/WKHnUPB3mX0X VXoBvpsYQRxrw== Received: from alfajor (unknown [216.154.43.249]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 868E9120242; Tue, 16 Mar 2021 18:54:13 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Message-ID: References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> Date: Tue, 16 Mar 2021 18:54:12 -0400 In-Reply-To: <87zgz3gfqo.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 16 Mar 2021 19:49:27 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.103 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= , Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > (let ((one-arg (equal (func-arity pred) '(1 . 1)))) Please don't. This will break down as soon as you set the function with `add-function`. [ I wish people could forget that `func-arity` exists. Its use is a bug-in-the-waiting in most cases. ] > (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) 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). Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 16 19:37:42 2021 Received: (at 46374) by debbugs.gnu.org; 16 Mar 2021 23:37:42 +0000 Received: from localhost ([127.0.0.1]:41444 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMJFu-0007Ho-Eh for submit@debbugs.gnu.org; Tue, 16 Mar 2021 19:37:42 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:52404) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMJFs-0007Hc-O6 for 46374@debbugs.gnu.org; Tue, 16 Mar 2021 19:37:41 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12GNOiMQ095477; Tue, 16 Mar 2021 23:37:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=nsTq0Y0kitWuu++9y86ZbDk2lMWXmATIT6WVSQrMjRU=; b=XlVRsoPYXxBkbUde8xwQ4z6JF9wtbGedKkwBkT91rQlc8IswSeRSc5LBGSzK/m+U4LAp frARFA853drlN/yh5qjHnJqMSIsAf/dkvwm/5b38k9vmGmvCLFPhLXRRHcaBvqMmUiR4 TpyOPkWU+mYRXPL9EtMJN/+bvTSVRSmkFBfFWSm6RuQZ9pk6XKUC4HX9UoF1bJ1hWIv5 YSUrSvNHfAIcs5e2ePc7tGXpKvUwbtV2QS+4BkidCekfjvGcNm41Bd/HoFDu2l/qtV0w f+dBoI+6jr6E3AcjXfR4AB6yWMtkyfKn2B1s9xqsgs1y8t7CIpyzJZjwr+sCXImfkv+L pQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 37a4ekq7dq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Mar 2021 23:37:33 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12GNPjwp123391; Tue, 16 Mar 2021 23:37:32 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by aserp3020.oracle.com with ESMTP id 3797a1v79r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Mar 2021 23:37:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C9hE4m5OHflk7Abh/p6XOsclK4ACJUHzFH7O/L0Cy9+Qs31tERcklRFGPCGL05ADr3gk6q6v8qvqyMD/XjFp4aQ2ZBr8FlGViIqVHnYLo1ds0jjnSMQFJbX5KkFZcGeplAx9jJEChqxDnh6c1eCxIfjxNnUduCbpo2HxHhT8iO+u6OF5isjJp2+VhQEW0E6QAng6+xjZEZJ6lhocBluEUNfzIrRn4ivtC1L1SSevhKBwX0EVxJioGJhMkXSD0lN8wOS26AxltGBr7vI2ItnLbGDpFg+YnFYenXPMZnTlSPw8Ff0Yzipvjf46oj2198Ypt8ndb8K/tcZlYeEHM+e39w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nsTq0Y0kitWuu++9y86ZbDk2lMWXmATIT6WVSQrMjRU=; b=AAqqZUMpGxW8gln3kcTHfEM/UjFMp4bIj4GhfKcsChozYsFF26jN0XmikicUJZQldbjsino5+EPQfjKkWq4m8te7DYXdLjXJxHAeIqwZKhkRJG7zREVUtXaOQqKctXUvxGPhZmId5wx4iWR8iZB57owSjiFp+JBLXIa8w3jEPuGxHwm8jBpmN96PhmoVUuwyOQCjkU3BREGTpD8XMwa/vc2Wkkw+KFfW5WqWdcrU2WMJ5ymDHgM7eNrkKIWH5qEAq79YWsGLTEQ2/fb9UFt4ZFdzdE8nGj76ZXMS/txCTIpxTNjMR7yteebmH9dlkOwrHSP6yVKyKxf17Uiro41V9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nsTq0Y0kitWuu++9y86ZbDk2lMWXmATIT6WVSQrMjRU=; b=wdxFXQUvSCn8/VVGMFsZ+ivSgYkO09Ss4rZUOPSiGZ8Rtf0hJ80lagI7wezfPDm1eixxJnagXY2LHSNBEQXj9SoNNOSiUE1UGRoSt+6UBu5DuRduhj87tKFe68XrPSv5hghKmS7f/f+oxohqKtBMKV0BNbCp+3EnFF8Tcp3r3HA= Received: from SA2PR10MB4474.namprd10.prod.outlook.com (2603:10b6:806:11b::15) by SA2PR10MB4411.namprd10.prod.outlook.com (2603:10b6:806:116::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.32; Tue, 16 Mar 2021 23:37:30 +0000 Received: from SA2PR10MB4474.namprd10.prod.outlook.com ([fe80::b8d2:db6d:3e4b:d315]) by SA2PR10MB4474.namprd10.prod.outlook.com ([fe80::b8d2:db6d:3e4b:d315%5]) with mapi id 15.20.3933.032; Tue, 16 Mar 2021 23:37:30 +0000 From: Drew Adams To: Stefan Monnier , Juri Linkov Subject: RE: [External] : bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Thread-Topic: [External] : bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Thread-Index: AQHXGrdyBgcO2v/AeUuE8re+EQd0DaqHOwdw Date: Tue, 16 Mar 2021 23:37:30 +0000 Message-ID: References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: iro.umontreal.ca; dkim=none (message not signed) header.d=none;iro.umontreal.ca; dmarc=none action=none header.from=oracle.com; x-originating-ip: [73.170.83.28] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6d85c11c-13d3-4004-c213-08d8e8d47761 x-ms-traffictypediagnostic: SA2PR10MB4411: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: OivpHdii4+AhVEy85M1tRDrnww0u/CWpPmUGis9Jy196ZgPcDdjzwOQJng3+U4khPC85BkFHFeRtkWma+Dfsepmy1aJgoeXDkpLeYLZXJXe7x6DazWNBZC/mQhUlKpLoLKNPso8wCop5xSdjISwJbYvaGzGJ/JVgbiJ+jlQaiUBDKsPUC0ScvJmZABFMd9Smm0UCzIQr09yKC9p+GAW/INTiF+MoRBuiVzF1Nml9pIHh+IaESzNvVC+CGbyBFadvq692UXgkYd6UyKH1otbXjzKlG2MX+wk+01IOUhNvoriahY6IoZl30Gl9CNw0wJV5qifzW0Xj8aT2YAuAtU44h5vl6SPzcyGo17wrcL0oJ87XVukKtlQApW8cpUX11QfP8vqytgRgF57+rh4PdDvqev0tjOvaynFFEZI1/Bd27qeXnLVHJ3hwfed7ikI7+O+6pRqvQABF/1NCES2DbN8dF/8CItLrF5IlMGMQqSxDYq2hqg5i/kkLrRVRmbqvrBzQQIm2/PAIUDt2J9BHqgovrkch9RgtG0SY7ev619yJrxM2l1p02NS28W7mc/CPFb3wO10w/z1C+bGHfs2vSl/o54J+GwqPzvpt6UDQOwhvxUe/gIzcpQTeN6WhmmRQDzNH0OoG1MAMX21vpXXr4uvc7g== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4474.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(366004)(376002)(396003)(136003)(39860400002)(52536014)(64756008)(110136005)(76116006)(5660300002)(66946007)(66556008)(66446008)(8676002)(83380400001)(478600001)(4326008)(6506007)(8936002)(71200400001)(54906003)(316002)(86362001)(2906002)(296002)(66476007)(186003)(26005)(33656002)(55016002)(7696005)(9686003)(44832011)(966005); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?utf-8?B?bFhxczd2cy9xeExYakZqWmplSDVwdXBYR2dGZ1RvTTg5NkROVzYyOXZ6elUv?= =?utf-8?B?MGVPMHZ3TC9aNDVOVmluMDBoVk95dHN1Nk9aMnAvV0lad3ZaeGlhV04zbnJD?= =?utf-8?B?ZHRWZ2V0cEd2cEh2T0pIenV4ZUhYZEtzY2tjNG9WY1htOXBwQlk4ZW5qMmZC?= =?utf-8?B?RnAvbTBBREpkSHlKMFBWbDNPekloSTljWGY0VVk1M0RpTXRCL3dZZEFYcEJ2?= =?utf-8?B?bDB6azVqODRuelM3d2EzeHFXZVRrU0xQTEF4aDA4YmxJRHZzSGFIdllncU1O?= =?utf-8?B?U2xoejZMUW5ZS0ZBdzAxSjBEdTd1SGJ0UE1YZTAwUjFBM3dUV2tySTJsUmZ0?= =?utf-8?B?VEZVZGFSaC9DY1kwYis4dUNvaEtjSjJ2V0ZXdlVLbUJkZTZXS0pYZTNQYUc5?= =?utf-8?B?Und6cWFSaWgyaU8xOHRUYXBEV0FtMVkwWTdocEE0U2YrT0dUK3FhQVM4WUlI?= =?utf-8?B?WVhWR09MSE5Hb3gyKzlVMDBoSkh4NjlGbURGc01xQ1ZGK2hpanU1bzY3Y3Jm?= =?utf-8?B?U2M5L1ZsSG4wSmpxWUZuZkpKcnZTSWEwUWV3WUdGcU1oY2RUbHlrdmxBTzFU?= =?utf-8?B?cmJ0QVpNVHYvd0t1dVZjNzVVZVpuS0gzdTNKNi8wN2kvRzdTSEkwbEt1MWdZ?= =?utf-8?B?M2JmdUUwdVIxVkRNeTl3SWdhcTlobHpCV2I0RWFHTGMrTEc1QzJNOHlDckVr?= =?utf-8?B?cDF5c3E2ZnN2Mkk1bm9hcXEvalF1Ny85elVZck10TkpKcEE2NWdaK1d0djk4?= =?utf-8?B?Nm9mczFKRWgrZndFV0dMQmkxRERUZTV4eHFSUmVZODEzQVZhMmFEaS9hcU5p?= =?utf-8?B?UXNtZzZtT0hYMTZyaURFYnhlSzAwbnNrL0RZajNkdm9xNE05Rjlyd2FyeUxy?= =?utf-8?B?QTJlY0FINkY3Z1kvTEVGWmo2OXRMQU9HREk5R0YrdSsybW5KU0hHNXJkeW1V?= =?utf-8?B?NHc1NnRVbTF1eHZQRWRTcFowYjJXaWpCL2Q5dG1FckR0WVcwTlFBY1JzNUdh?= =?utf-8?B?MURKSFNGVnBWcTRNS3M5dFdCRWo1UGUzZWJBVldNckJpb3Y3TFZIWGQ2ZTNK?= =?utf-8?B?c0pqQlp4cXJkSStWR1Q5ek42bmJWK3o0QVhhVEg2MHNnd2RQaDR2bEs3RnEz?= =?utf-8?B?RmxycFV5WXhyWXIzS2lXYUtyN0xQc0Y0bklIWlo3SG91ODJtMnZYaG5XV3pF?= =?utf-8?B?Ui9DekJFYlpvdUE2RTNXeUhoY0w4S0hZV3lRRmRvaDNPYTg1Qk5aUURwRGJL?= =?utf-8?B?dkg2R0drOUJFVUVoaVRzVmJ1cFVhaE94bEpQb1l2b3B4K1hXTDR2c05ER3Fj?= =?utf-8?B?T2RnOGI1VmNuVitYM1ovYThZYng3c09sRkNrWHlOdUFROFpnSFJVaE85eEdX?= =?utf-8?B?dEdZZHM1Y3hGQk9TS1M1L3pNT1o5N3B3Y3FjLy9XWGtKVVZsSU1nR2pIVkJX?= =?utf-8?B?Ukt5VFNrRldVZzNLU2FMaXd0R291VW04c3A1N2NZZEJpdmdHV2lwSnQ1K3BY?= =?utf-8?B?WWFFV1lPcVZ4c3RlM2xRWnJjOW9XY2tUN1NkOXpyek85MnQzem82Z1hoK2c5?= =?utf-8?B?NlRabVVhSk5COTZJOUxSOVZDdmRoOXBEK3hRSU1RSHZkT01JT1BrYmVFUHZ2?= =?utf-8?B?akxVbi9hTUdYVmFNV2ZjNE5oeGZTcWh4bnFRMGVOd3cvUFE2Nzlxc2puTUNi?= =?utf-8?B?L1RDUGFzeVNKWnB0bFZQWTNMSWpVWlo2R3NDTTdGVXNRSWZibVE3WmtVNXVx?= =?utf-8?Q?lclzhpGmV8Ikfmcj0AEXzwdN4A76rV+ZR+YdCq9?= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4474.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d85c11c-13d3-4004-c213-08d8e8d47761 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Mar 2021 23:37:30.5655 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LEvSwo/NCmZssEM6DANB/oazSVle7PdDYZxu2W9aYhrt1Uw4cEQyrkbiwXSDGlwKmEL7hWoKTP9brBc5Bm+jYA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4411 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9925 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103160153 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9925 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 adultscore=0 phishscore=0 suspectscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103160153 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 46374 Cc: "46374@debbugs.gnu.org" <46374@debbugs.gnu.org>, =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= , Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) PiBQbGVhc2UgZG9uJ3QuICBUaGlzIHdpbGwgYnJlYWsgZG93biBhcyBzb29uIGFzIHlvdQ0KPiBz ZXQgdGhlIGZ1bmN0aW9uIHdpdGggYGFkZC1mdW5jdGlvbmAuDQo+DQo+IFsgSSB3aXNoIHBlb3Bs ZSBjb3VsZCBmb3JnZXQgdGhhdCBgZnVuYy1hcml0eWAgZXhpc3RzLiAgDQo+ICAgSXRzIHVzZSBp cyBhIGJ1Zy1pbi10aGUtd2FpdGluZyBpbiBtb3N0IGNhc2VzLiBdDQoNClllYWguICBCdXQgbWF5 YmUgRW1hY3MgTGlzcCBjYW4gaGF2ZSBhIHNsaWdodGx5IGJldHRlcg0KZnVuY3Rpb24gdGhhdCBk b2VzIHNvbWV0aGluZyBsaWtlIHdoYXQgaXQgdHJpZXMgdG8gZG8/DQoNClRoaXMgd2FzIGludHJv ZHVjZWQgaW4gRW1hY3MgMjYsIElJVUMuICBJdCdzIG5vdCBsaWtlDQppdCdzIG9sZCBjcnVmdC4g IChNYXliZSBuZXcuIDstKSkNCg0KSGVyZSdzIHdoYXQgc29tZSBoYXZlIGNvbWUgdXAgd2l0aCBm b3IgQ29tbW9uIExpc3A6DQoNCmh0dHBzOi8vc3RhY2tvdmVyZmxvdy5jb20vcS8xNTQ2NTEzOC83 Mjk5MDcNCg0KQXMgbG9uZyBhcyBgZnVuYy1hcml0eScgZXhpc3RzLCBob3cgYWJvdXQgZG9jdW1l bnRpbmcNCnBhcnRpY3VsYXIgY2FzZXMgd2hlcmUgaXQgY2FuIGxpa2VseSBjYXVzZSB0cm91Ymxl LCBvcg0KY2FzZXMgd2hlcmUgaXQncyBsZXNzIGxpa2VseSB0byBjYXVzZSB0cm91YmxlLCB0byBn aXZlDQp1c2VycyBzb21lIGd1aWRhbmNlIChiZXlvbmQgIlBsZWFzZSBkb24ndCB1c2UgaXQiKT8N Cg0KSWYgaXQncyBwcm9ibGVtYXRpYyB3aGVuIHVzZWQgd2l0aCB0aGluZ3MgbGlrZQ0KYGFkZC1m dW5jdGlvbicsIGlzIHRoZXJlIHNvbWV0aGluZyB0aGF0IGNhbiBiZSBzYWlkDQphYm91dCBwYXJ0 aWN1bGFyIHVzZXMgdGhhdCBhcmUgbW9yZSBvciBsZXNzIGxpa2VseSB0bw0KY2F1c2UgdHJvdWJs ZT8gIElPVywgYWdhaW4sIGNhbiB3ZSBzYXkgbW9yZSB0aGFuIGp1c3QNCiJEb24ndCB1c2UgaXQi Pw0KDQpJJ20gZ3Vlc3NpbmcgdGhhdCBtYW55IHVzZSBjYXNlcyBvZiBgZnVuYy1hcml0eScgdHJ5 DQp0byBzYW5pdHktdGVzdCB0aGluZ3MgbGlrZSB3aGV0aGVyIGFuIHVua25vd24gZnVuY3Rpb24N CmNhbiBhY2NlcHQgemVybyBhcmdzIChub25lIHJlcXVpcmVkKSwgb3IgY2FuIGFjY2VwdCBhdA0K bGVhc3Qgb25lIGFyZywgZXRjLiAgSWYgc3VjaCB0ZXN0cyBhcmUgY29uc2VydmF0aXZlDQp0aGV5 IGNhbiBzb21ldGltZXMgYmUgbW9yZSBoZWxwIHRoYW4ganVzdCB0ZXN0aW5nDQp3aGV0aGVyIGFu IG9iamVjdCBpcyBgZnVuY3Rpb25wJy4NCg0KSU9XLCBkZXBlbmQgb24gdGhlIGBmdW5jLWFyaXR5 JyByZXR1cm4gdmFsdWUgb25seSBpbg0KYSBjb25zZXJ2YXRpdmUgZGlyZWN0aW9uOyBkb24ndCBj b3VudCBvbiBpdCBhcyBhbnkNCmtpbmQgb2YgZ3VhcmFudGVlIHRoYXQgeW91IF9jYW5fIGRvIHNv bWV0aGluZywgYnV0IHVzZQ0KaXQgYXMgYSBjaGVjayB0aGF0IHlvdSBtaWdodCBub3Qgd2FudCB0 byBib3RoZXIgdG8gdHJ5DQp0byBkbyBpdC4NCg0KQW4gYWx0ZXJuYXRpdmUgZm9yIGF0IGxlYXN0 IHNvbWUgdXNlIGNhc2VzIGlzIHRvIHRyeQ0KZnVuY2FsbGluZyBhIGZ1bmN0aW9uIHdpdGggc29t ZSAocG9zc2libHkgZW1wdHkpIGFyZw0KbGlzdCwgYW5kIHNlZSB3aGV0aGVyIHRoYXQgcmFpc2Vz IGFuIGVycm9yLiAgQnV0DQpzb21ldGltZXMgdGhhdCBtaWdodCBub3QgYmUgd2hhdCB5b3UgcmVh bGx5IHdhbnQgdG8gZG8uDQoNCkNsZWFybHksIGZ1bmN0aW9ucyBhcmUgZXNzZW50aWFsbHkgb3Bh cXVlLCBhcyBkYXRhLA0KYXQgbGVhc3QgaW4gb3VyIGVudmlyb25tZW50LiAgU3RpbGwsIHNvbWUg dGhpbmdzIGNhbg0KYmUgZG9uZSwgZXZlbiBpZiBsaW1pdGVkIGFuZCB0ZW50YXRpdmUuDQo= From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 17 13:25:01 2021 Received: (at 46374) by debbugs.gnu.org; 17 Mar 2021 17:25:02 +0000 Received: from localhost ([127.0.0.1]:43918 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMZun-0004oY-EM for submit@debbugs.gnu.org; Wed, 17 Mar 2021 13:25:01 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:35523) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMZum-0004o6-8v for 46374@debbugs.gnu.org; Wed, 17 Mar 2021 13:25:00 -0400 X-Originating-IP: 91.129.107.223 Received: from mail.gandi.net (m91-129-107-223.cust.tele2.ee [91.129.107.223]) (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 144FFE0007; Wed, 17 Mar 2021 17:24:51 +0000 (UTC) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> Date: Wed, 17 Mar 2021 19:10:15 +0200 In-Reply-To: (Stefan Monnier's message of "Tue, 16 Mar 2021 18:54:12 -0400") Message-ID: <87blbhhghk.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= , Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > 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)))) From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 17 13:25:08 2021 Received: (at 46374) by debbugs.gnu.org; 17 Mar 2021 17:25:08 +0000 Received: from localhost ([127.0.0.1]:43924 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMZut-0004pV-Ta for submit@debbugs.gnu.org; Wed, 17 Mar 2021 13:25:08 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:50111) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMZuq-0004oG-Nf for 46374@debbugs.gnu.org; Wed, 17 Mar 2021 13:25:05 -0400 X-Originating-IP: 91.129.107.223 Received: from mail.gandi.net (m91-129-107-223.cust.tele2.ee [91.129.107.223]) (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 16BA2FF80C; Wed, 17 Mar 2021 17:24:55 +0000 (UTC) From: Juri Linkov To: Drew Adams Subject: Re: [External] : bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> Date: Wed, 17 Mar 2021 19:12:20 +0200 In-Reply-To: (Drew Adams's message of "Tue, 16 Mar 2021 23:37:30 +0000") Message-ID: <87zgz1g1va.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: "46374@debbugs.gnu.org" <46374@debbugs.gnu.org>, Tino Calancha , Stefan Monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > As long as `func-arity' exists, how about documenting > particular cases where it can likely cause trouble Everything is already documented in (info "(elisp) What Is a Function"): Note that this function might return inaccurate results in some situations, such as the following: − Functions defined using ‘apply-partially’ (*note apply-partially: Calling Functions.). − Functions that are advised using ‘advice-add’ (*note Advising Named Functions::). − Functions that determine the argument list dynamically, as part of their code. From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 21 13:59:14 2021 Received: (at 46374) by debbugs.gnu.org; 21 Mar 2021 17:59:15 +0000 Received: from localhost ([127.0.0.1]:55470 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lO2M6-0003Z1-KB for submit@debbugs.gnu.org; Sun, 21 Mar 2021 13:59:14 -0400 Received: from mail-wr1-f48.google.com ([209.85.221.48]:34377) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lO2M4-0003Yo-DF for 46374@debbugs.gnu.org; Sun, 21 Mar 2021 13:59:13 -0400 Received: by mail-wr1-f48.google.com with SMTP id j7so14339491wrd.1 for <46374@debbugs.gnu.org>; Sun, 21 Mar 2021 10:59:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=zCW9fHcpDkW9Ozyh5CGEDwZE5Ztg2Uzh3B4AoOqXuPg=; b=g+Ix3hT8YXEXc/oUHRQpNFsQUO5xbZvcQB9hU9tYoSV3Tm9GgfWPMPU9HfT2G6pu+I G1W/yY/ANpNc6IQCZCiOBPy2xemwAIsHICy8s8GnUIsM90nBisbghRpjvau/YhK+DJPe CUgvmvvjqKuiNsTWe5WeH1vx27ocVujlRFp27LJzFf5CvCkXiUtmnUx7Wci1AXyAqz0N zxX1+Ujzi8lx3fEtbWEq6MQWXVT10yTFr6g9fqTgmcZZO00EnfuMPl+tDFRjp+zSwxLv oTxlLa5x8MSEr20gejKH/89nZ2mASp5ketVgZHt/spSN8KHFxvwVCerEUZDXMI5zSeBT A/MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=zCW9fHcpDkW9Ozyh5CGEDwZE5Ztg2Uzh3B4AoOqXuPg=; b=moHVegrAfHhcC5g55PUvsm54Y40VrjwAgco2gTtrsh2K8vGnY1sx8NlbLoqMdJMvCg wL5Mo/RxdfJEO14iHHids8y+exnGzNUSizZC/uEzx+I3m6tlfczxfZUXDqKU89DeSVV8 OU/YfXBnE/764h6bKYDlcIcbF/QRwISBV2L7K1UAAg1ia6SMRzP0Jqlya4+8YpW1iKUL s+Gr+ZUfrAw1w0AkhYuLq58QeZLhnIngH6wImsoyX14R6Tvs+J3o/g8y9KsRrWkKPWE5 QSbY59JZtwfROni75SZVXUwk2elSQta0udehMGUX3qIUbkI3S7w9K5RCsgudnA1THT1t RcLA== X-Gm-Message-State: AOAM531W94REd6PZsiPnRD1WepWLBvoFTr8RM3H2yPVi673EOpUxZAU9 BkNyFJO7vi1ZXvIasYs0cKI= X-Google-Smtp-Source: ABdhPJz2olAJm8noiH9gcHOabIPAVFJNHI1r6uXz9kzqRDgOsnLvVrt8NilmM0SM/UIKUVo55Q6P/g== X-Received: by 2002:a05:6000:156e:: with SMTP id 14mr3899977wrz.198.1616349546341; Sun, 21 Mar 2021 10:59:06 -0700 (PDT) Received: from localhost.example.com ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id m9sm17318192wro.52.2021.03.21.10.59.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Mar 2021 10:59:05 -0700 (PDT) From: Tino Calancha To: Juri Linkov Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> Date: Sun, 21 Mar 2021 18:59:04 +0100 In-Reply-To: <87blbhhghk.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 17 Mar 2021 19:10:15 +0200") Message-ID: <87pmzsgzh3.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Juri Linkov writes: >> 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)))) Thanks Juri and Stefan; it looks more general now. I have noticed that I haven't enabled lexical-binding in my .emacs file, which it is crucial for my use case. To avoid surprises, I have mentioned this issue in the docstring. --8<-----------------------------cut here---------------start------------->8--- diff --git a/lisp/files.el b/lisp/files.el index dada69c145..e87fbe9599 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5520,6 +5520,28 @@ save-some-buffers-default-predicate :type '(choice (const :tag "Default" nil) function) :version "26.1") +(defvar save-some-buffers-fun-function (lambda () save-some-buffers-default-predicate) + "Overrides the behavior of `save-some-buffers-default-predicate'. +This variable's value should be a function, which will be called +by `save-some-buffers' with no arguments to override the default predicate. +This allow you to capture variables in the environment of `save-some-buffers', +and use them to decide which buffers must be saved. +For instance, the following expression restricts to save only buffers inside +the project from where `save-some-buffers' is invoked, or under the +caller's `default-directory' if no project is found: + +\(lambda () + (let ((project-dir + (or (and (project-current) (project-root (project-current))) + default-directory))) + (lambda () (file-in-directory-p default-directory project-dir)))) + +Note that, the example above requires that you evaluate this expression +in a file or buffer with lexical binding enabled.") + +(defun save-some-buffers-fun () + (funcall save-some-buffers-fun-function)) + (defun save-some-buffers (&optional arg pred) "Save some modified file-visiting buffers. Asks user about each one. You can answer `y' or SPC to save, `n' or DEL not to save, `C-r' @@ -5547,8 +5569,17 @@ save-some-buffers change the additional actions you can take on files." (interactive "P") (unless pred - (setq pred save-some-buffers-default-predicate)) + (setq pred (save-some-buffers-fun))) + --8<-----------------------------cut here---------------end--------------->8--- From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 21 16:44:09 2021 Received: (at 46374) by debbugs.gnu.org; 21 Mar 2021 20:44:09 +0000 Received: from localhost ([127.0.0.1]:55542 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lO4vh-00016v-An for submit@debbugs.gnu.org; Sun, 21 Mar 2021 16:44:09 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:4311) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lO4vb-000162-6b for 46374@debbugs.gnu.org; Sun, 21 Mar 2021 16:44:03 -0400 X-Originating-IP: 91.129.107.223 Received: from mail.gandi.net (m91-129-107-223.cust.tele2.ee [91.129.107.223]) (Authenticated sender: juri@linkov.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 1FE59240004; Sun, 21 Mar 2021 20:43:54 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> Date: Sun, 21 Mar 2021 22:10:04 +0200 In-Reply-To: <87pmzsgzh3.fsf@gmail.com> (Tino Calancha's message of "Sun, 21 Mar 2021 18:59:04 +0100") Message-ID: <87o8fc5jq0.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > I have noticed that I haven't enabled lexical-binding in my .emacs file, > which it is crucial for my use case. > To avoid surprises, I have mentioned this issue in the docstring. Unfortunately, your patch is truncated. Could you send a complete patch? From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 18 10:27:43 2021 Received: (at 46374) by debbugs.gnu.org; 18 Apr 2021 14:27:43 +0000 Received: from localhost ([127.0.0.1]:47378 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lY8Ol-00024D-6Y for submit@debbugs.gnu.org; Sun, 18 Apr 2021 10:27:43 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:36802) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lY8Oj-00023v-C8 for 46374@debbugs.gnu.org; Sun, 18 Apr 2021 10:27:41 -0400 Received: by mail-wr1-f53.google.com with SMTP id m9so18562500wrx.3 for <46374@debbugs.gnu.org>; Sun, 18 Apr 2021 07:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=zlyHAoi4SDiOweTVg2MqDCkESCYmDig2Jn9VMAXqsE0=; b=RhI+/khcnq3iiDaIjN5Ja2qeBdf8iLyAUlahUJc7AapqpoIki0Xb5oEQJXGG2t8MWl zCINpvqthNAKO8gJYxhemDNAGvHtBUkb8ItL5zMc/d7gJE1Zdu8o5muRVGmQwl6qGVJQ hnJ94s7CpXe9i7fTblW7QRpCXPVrDzzndBK4eZqLSqk0thErlgWu63/JDkpdqPCtTwbi PrdknMnFKjTSo0eNWE/HT5oNeiHSdavS9BaM8n8TgG/doU8T7QUrXvfTMjnD+HgUUwDN pHQvPweq0oZ9e+C9d/D/CemzLlFXRiaRP5V6Ye2pIWQNp5Pxrd4fb2BEPrI8SlEUYuj4 cHOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=zlyHAoi4SDiOweTVg2MqDCkESCYmDig2Jn9VMAXqsE0=; b=nhWEtZebRbX20RIen+r5Eq/TDrOKn6ZuAREtWHXJdktDr+vYu6XLoXMgMP/tIPNrv5 Lm2EreJQKg0p/q7nFB20dzdK2P1KDzuIEPhwwdCJxl2NI1iSRAgtD7Buv8bBlJZo4vqa riTOqs5/mCsWCiBNyfAhWgRHlVqssWVHv+v8mIyiy/AE8vNKtQRjp2bbM2wyBKTObyyz EAN33bWkQTUhCc1RZfNR9qbE+czzN4ueBAWDxNS1eAo1WllPgSgKKMto5nqS1engPm+N xVupVM0p264jLcLEcCqHEmUGG+sAo9E6WG1Jto95adMH/bQH0T9oNd0zF+3B21mUFYxz X+PA== X-Gm-Message-State: AOAM533PoKIUtIRkCrVn1fQNZ8Eg78b8lCurq3YJUmmuo8gJjRknX5nZ vISe+aTPVxOnOHILd6YYMU8= X-Google-Smtp-Source: ABdhPJx2bz4kp5R9mBstfOv6K8N0PtZ/ZI31JNyd5RszKpfvCPLXj44zUWVB2qyFTeGoKnE7JyXetQ== X-Received: by 2002:a05:6000:1084:: with SMTP id y4mr9491967wrw.364.1618756055477; Sun, 18 Apr 2021 07:27:35 -0700 (PDT) Received: from localhost.example.com ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id t6sm18513672wrx.38.2021.04.18.07.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Apr 2021 07:27:34 -0700 (PDT) From: Tino Calancha To: Juri Linkov Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> Date: Sun, 18 Apr 2021 16:27:33 +0200 In-Reply-To: <87o8fc5jq0.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 21 Mar 2021 22:10:04 +0200") Message-ID: <87wnsz7jmy.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Juri Linkov writes: >> I have noticed that I haven't enabled lexical-binding in my .emacs file, >> which it is crucial for my use case. >> To avoid surprises, I have mentioned this issue in the docstring. > > Unfortunately, your patch is truncated. Could you send a complete patch? Here is: --8<-----------------------------cut here---------------start------------->8--- commit 73b2ff479ab1f9af399e6d09ceff85bb8eaa66b0 Author: Tino Calancha Date: Sun Apr 18 16:14:13 2021 +0200 patch for Bug#46374 On top of commit 2822246b5d8154d0166e17ffd28a1d85b57d68aa diff --git a/lisp/files.el b/lisp/files.el index 7440c11a21..56ef949eeb 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5520,6 +5520,28 @@ save-some-buffers-default-predicate :type '(choice (const :tag "Default" nil) function) :version "26.1") +(defvar save-some-buffers-fun-function (lambda () save-some-buffers-default-predicate) + "Overrides the behavior of `save-some-buffers-default-predicate'. +This variable's value should be a function, which will be called +by `save-some-buffers' with no arguments to override the default predicate. +This allow you to capture variables in the environment of `save-some-buffers', +and use them to decide which buffers must be saved. +For instance, the following expression restricts to save only buffers inside +the project from where `save-some-buffers' is invoked, or under the +caller's `default-directory' if no project is found: + +\(lambda () + (let ((project-dir + (or (and (project-current) (project-root (project-current))) + default-directory))) + (lambda () (file-in-directory-p default-directory project-dir)))) + +Note that, the example above requires that you evaluate this expression +in a file or buffer with lexical binding enabled.") + +(defun save-some-buffers-fun () + (funcall save-some-buffers-fun-function)) + (defun save-some-buffers (&optional arg pred) "Save some modified file-visiting buffers. Asks user about each one. You can answer `y' or SPC to save, `n' or DEL not to save, `C-r' @@ -5547,7 +5569,7 @@ save-some-buffers change the additional actions you can take on files." (interactive "P") (unless pred - (setq pred save-some-buffers-default-predicate)) + (setq pred (save-some-buffers-fun))) (let* ((switched-buffer nil) (save-some-buffers--switch-window-callback (lambda (buffer) --8<-----------------------------cut here---------------end--------------->8--- From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 24 18:21:46 2021 Received: (at 46374) by debbugs.gnu.org; 24 Apr 2021 22:21:46 +0000 Received: from localhost ([127.0.0.1]:41651 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1laQeo-0003RP-6x for submit@debbugs.gnu.org; Sat, 24 Apr 2021 18:21:46 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:39863) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1laQel-0003RB-VM for 46374@debbugs.gnu.org; Sat, 24 Apr 2021 18:21:45 -0400 X-Originating-IP: 91.129.102.166 Received: from mail.gandi.net (m91-129-102-166.cust.tele2.ee [91.129.102.166]) (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 53BCEE0003; Sat, 24 Apr 2021 22:21:34 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> Date: Sun, 25 Apr 2021 01:13:13 +0300 In-Reply-To: <87wnsz7jmy.fsf@gmail.com> (Tino Calancha's message of "Sun, 18 Apr 2021 16:27:33 +0200") Message-ID: <87tunvnxfo.fsf@linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >>> I have noticed that I haven't enabled lexical-binding in my .emacs file, >>> which it is crucial for my use case. >>> To avoid surprises, I have mentioned this issue in the docstring. >> >> Unfortunately, your patch is truncated. Could you send a complete patch? > > Here is: Thanks. Your first patch was better in terms of customizability. It allowed the users to easily customize the used predicate, but its disadvantage was that it introduced a new defcustom. Would it be possible to merge the advantage of your first patch with the cleaner solution of your latest patch? > +(defvar save-some-buffers-fun-function (lambda () save-some-buffers-default-predicate) Maybe it's possible to hard-code this as the default option of the existing defcustom save-some-buffers-default-predicate? Currently there is such FIXME comment in save-some-buffers-default-predicate: ;; FIXME nil should not be a valid option, let alone the default, ;; eg so that add-function can be used. Is it possible to add the default value as a function that returns nil? This will implement FIXME, and will allow adding more options with more predicates: > +\(lambda () > + (let ((project-dir > + (or (and (project-current) (project-root (project-current))) > + default-directory))) > + (lambda () (file-in-directory-p default-directory project-dir)))) Then this code could be implemented as an additional option for save-some-buffers-default-predicate. From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 28 15:31:40 2021 Received: (at 46374) by debbugs.gnu.org; 28 Apr 2021 19:31:40 +0000 Received: from localhost ([127.0.0.1]:54115 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbpuO-0006nJ-1v for submit@debbugs.gnu.org; Wed, 28 Apr 2021 15:31:40 -0400 Received: from mail-wm1-f46.google.com ([209.85.128.46]:42531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbpuJ-0006n2-Jt for 46374@debbugs.gnu.org; Wed, 28 Apr 2021 15:31:39 -0400 Received: by mail-wm1-f46.google.com with SMTP id a22-20020a05600c2256b029014294520f18so5113832wmm.1 for <46374@debbugs.gnu.org>; Wed, 28 Apr 2021 12:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=msDiSo1F+Euw8uSa6BVTsjLQPBNnnBOZcywenYY0A6E=; b=rrgy9gF4p8jtmFFDWGPEXIssbhyO+fBpGSI2sPfVYIkMXbwPbbw4ElacCtyAFn2dvH eiYkVmtnTMlwIUuJajYY2LHMSYvmTXvz2TQaBQ+94X2oIxJb8x0SPfXsxUA/E8lLwFCz XwtN7ghpVVd2QYFSD6kWZaE4fFVW1WARk/9jK0am6ZKYj1ZpsKguhCItDy3XqXbquJUT TFqRrV7v6YdSRxs9uWP+6xMYHp/Sg4UgZo0Tbq0PVguRLurUdQZtoVrYn5lHdFi4k92A gFrJenPDnNwsEKMLYPcikwQmj7T/QdbEhD6Y8ijeWC0tNxyGtEr2S9bUhQArEYI6Z6nU p6KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=msDiSo1F+Euw8uSa6BVTsjLQPBNnnBOZcywenYY0A6E=; b=lUobxk+mIV6wFzRlpf7ySdKX97X6pjgdW9uP+Uk2W2xlAs+6j2W5LD2IgkYMPYvU03 DJVjODrKekfwayuDUmO7aF+vBhVrD/3HZoG7D1hO/eps0HS2c0FunYZ0fLyYdELmgQcP /WAri5lLcTLc9xok9G7jXDZ/qz7ukOx2lly9byS9NqFCT5/eDakU7BuiyW8fleijnG8N HhCAVojfzivqbyXIsH2nJ94k/G+vb17uM3aQL/CXlg75eUasyd6nxcdGDpH2XFdYmAbp TYkmAAmRi5rtYty1bkAVnSu7/2X6Yocp7cQXCuhNWpzkWEISMgpWTPHUSHXF8AGpDwwV S3dQ== X-Gm-Message-State: AOAM532MBZmNa8/JCM9MzfVjDwRysflH39ry4aFRy/RY2zW3lEhaT59K Jc4wYKfqvlGeRvNxuhbac+Q= X-Google-Smtp-Source: ABdhPJx3b412qhe2ShV387AbrfKPhNAcmH2ennrrRIN4SoR8TBK+GktiwBLtY8Ca/+8XmpHWoJ5qBQ== X-Received: by 2002:a1c:a50d:: with SMTP id o13mr6195371wme.161.1619638288518; Wed, 28 Apr 2021 12:31:28 -0700 (PDT) Received: from localhost.example.com ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id x8sm977835wru.70.2021.04.28.12.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 12:31:27 -0700 (PDT) From: Tino Calancha To: Juri Linkov Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> <87tunvnxfo.fsf@linkov.net> Date: Wed, 28 Apr 2021 21:31:25 +0200 In-Reply-To: <87tunvnxfo.fsf@linkov.net> (Juri Linkov's message of "Sun, 25 Apr 2021 01:13:13 +0300") Message-ID: <87h7jq1a0i.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Juri Linkov writes: > Your first patch was better in terms of customizability. > but its disadvantage was that it introduced a new defcustom. > > Would it be possible to merge the advantage of your first patch > with the cleaner solution of your latest patch? Good idea. > Is it possible to add the default value as a function that returns nil? > This will implement FIXME, and will allow adding more options > with more predicates: 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] --8<-----------------------------cut here---------------start------------->8--- commit 3abcf022a1fb375f15df8438ebf0cf5b67082bbc Author: Tino Calancha Date: Wed Apr 28 21:18:28 2021 +0200 Merge the two approaches * lisp/files (some-buffers-default-predicate): Redefined; store a function that builds the actual predicate used in save-some-buffers. On top of commit 0c7f1e2e42d6bf9f95e88c02d4e1ed9cb40693d8 diff --git a/lisp/files.el b/lisp/files.el index 8e8fbac8dc..707c6a77bc 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5512,19 +5512,37 @@ save-some-buffers-action-alist (defvar-local buffer-save-without-query nil "Non-nil means `save-some-buffers' should save this buffer without asking.") -(defcustom save-some-buffers-default-predicate nil - "Default predicate for `save-some-buffers'. +(defvar save-some-buffers-default-fun (lambda () nil)) -This allows you to stop `save-some-buffers' from asking -about certain files that you'd usually rather not save. +(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))))) -This function is called (with no parameters) from the buffer to -be saved." +(defcustom save-some-buffers-default-predicate save-some-buffers-default-fun + "Generator function of the default predicate for `save-some-buffers'. + +It must be a function with no arguments that returns a predicate. +This predicate is called (with no parameters) from the buffer to be +saved. + +This allows you to stop `save-some-buffers' from asking about certain +files that you'd usually rather not save. + +The default value builds a predicate that prompts to save any modified +file-visiting buffer. The second value restricts to buffers inside +the project from where `save-some-buffers' is invoked, or under the +caller's `default-directory' if no project is found." :group 'auto-save - ;; 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) - :version "26.1") + :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)) + :version "28.1") + +(defun save-some-buffers-fun () + (funcall save-some-buffers-default-predicate)) (defun save-some-buffers (&optional arg pred) "Save some modified file-visiting buffers. Asks user about each one. @@ -5553,7 +5571,8 @@ save-some-buffers change the additional actions you can take on files." (interactive "P") (unless pred - (setq pred save-some-buffers-default-predicate)) + (setq pred (save-some-buffers-fun))) + (let* ((switched-buffer nil) (save-some-buffers--switch-window-callback (lambda (buffer) --8<-----------------------------cut here---------------end--------------->8--- From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 28 16:00:48 2021 Received: (at 46374) by debbugs.gnu.org; 28 Apr 2021 20:00:48 +0000 Received: from localhost ([127.0.0.1]:54142 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbqMa-0007Uv-H8 for submit@debbugs.gnu.org; Wed, 28 Apr 2021 16:00:48 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:56301) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbqMY-0007Uh-NB for 46374@debbugs.gnu.org; Wed, 28 Apr 2021 16:00:47 -0400 X-Originating-IP: 91.129.102.166 Received: from mail.gandi.net (m91-129-102-166.cust.tele2.ee [91.129.102.166]) (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 4E8B4E0006; Wed, 28 Apr 2021 20:00:38 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> <87tunvnxfo.fsf@linkov.net> <87h7jq1a0i.fsf@gmail.com> Date: Wed, 28 Apr 2021 22:51:51 +0300 In-Reply-To: <87h7jq1a0i.fsf@gmail.com> (Tino Calancha's message of "Wed, 28 Apr 2021 21:31:25 +0200") Message-ID: <87zgxigpbc.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > 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. From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 28 16:35:13 2021 Received: (at 46374) by debbugs.gnu.org; 28 Apr 2021 20:35:13 +0000 Received: from localhost ([127.0.0.1]:54172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbqtt-0008K6-G8 for submit@debbugs.gnu.org; Wed, 28 Apr 2021 16:35:13 -0400 Received: from mail-wm1-f44.google.com ([209.85.128.44]:53020) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbqtq-0008Jh-GW for 46374@debbugs.gnu.org; Wed, 28 Apr 2021 16:35:12 -0400 Received: by mail-wm1-f44.google.com with SMTP id g65so5403281wmg.2 for <46374@debbugs.gnu.org>; Wed, 28 Apr 2021 13:35:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:message-id:mime-version; bh=14hCLY1HcYVs1REhDQGTkHubrisiAzVMr4nHuRsUDiQ=; b=HVF63IMhpgZWx/Q1TKD4kPD1Gwu9Ej/42RSjSAtTKKI+p9n558iEr/aYE+Y/JmKGIQ 6JFA+OiZdhOjRmpnBlezBD4+aAf3xoXFjcTyuKt/sX/ZtcOhs3H0v7wzI93ILB88F5h0 y6d/XnAI+iGPLGsTRZR10eTil5vbUvRSGz5BnbaSBW6mj9v1Udp+pGbigNn+qyUtpLPu jgP/e9eNwqXVZ9+K8obWN1LGcPrDm7qRmciL1ORbbzLwDffG6iS1CAZfbEmgBtegLgHK IuSmLuSKmioAn2zEjih8cveboKYb94mBQxJ3iXJ9fGW2CNjtKEOk8t8wqjGQ2nk7BKfP FbMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:message-id :mime-version; bh=14hCLY1HcYVs1REhDQGTkHubrisiAzVMr4nHuRsUDiQ=; b=ZJ2yfbUnErB4oUOw24o3KwuqRHF8Krmac0uwC4Ekz6xC6uOSx8iet1vT34wd3zRWcV j1w7+5lcgHNeE36hBci27+hJF3ajBlIBgaLuyjHZgnK+tMtkRWQclpX7YZ3uX9TrdHJM HI2Rh5r2InVa4zbilIL/0pKxLVjN6AW1ggC1XFLW0PcFgIoiICp8MJj2WOdTSPSUjy26 knTJ63Fs9QyaP57+BfcPwKfgQXwF5e9yQFFEu+zUcwdbHa0LGftchc3meW5lNA+cVrAQ Om4hX93ppNkyNLUs464P6B5OjTlJLXyOg1Fc8nn/BahOu1+8MlLBYSHrQ9HIFQM8ljAg x1qg== X-Gm-Message-State: AOAM530tgkIhZ+Mne3pLqesZ/7GNQhVG3gW5k90IDLTkXYnQGcDWRmfm 2hBYtPNjzyPo8i4HCe5GBlI= X-Google-Smtp-Source: ABdhPJwKLBzLPhC3SCG/Vi49ZwXMWOwNErLwbBV1IC8HKREeTnsx2lDBJRU1PUMJmVawVX5lz5QkwA== X-Received: by 2002:a05:600c:d5:: with SMTP id u21mr32883084wmm.153.1619642104662; Wed, 28 Apr 2021 13:35:04 -0700 (PDT) Received: from localhost.example.com ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id z7sm1311483wrl.11.2021.04.28.13.35.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 13:35:03 -0700 (PDT) From: Tino Calancha To: Juri Linkov Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> <87tunvnxfo.fsf@linkov.net> <87h7jq1a0i.fsf@gmail.com> <87zgxigpbc.fsf@mail.linkov.net> Date: Wed, 28 Apr 2021 22:35:02 +0200 Message-ID: <87eeeu172h.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Juri Linkov writes: > (defun save-some-buffers-fun () > (funcall save-some-buffers-default-predicate)) > > I see a problem in save-some-buffers-fun: what if > save-some-buffers-default-predicate is still customized to nil? I assumed we were OK with the backward incompatible change; I mean, with requiring from now on `save-some-buffers-default-predicate' to be a function generating the predicate. > 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. We can do that; but it seems to me that the spirit of the FIXME comment is in the line to not accept `nil' as a valid value, just functions. BYW, thanks for testing the patch. From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 29 05:16:48 2021 Received: (at 46374) by debbugs.gnu.org; 29 Apr 2021 09:16:48 +0000 Received: from localhost ([127.0.0.1]:54827 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lc2mu-0006Cf-3X for submit@debbugs.gnu.org; Thu, 29 Apr 2021 05:16:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51418) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lc2mr-0006CS-Ne for 46374@debbugs.gnu.org; Thu, 29 Apr 2021 05:16:47 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:38893) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lc2ml-0002Pe-2b; Thu, 29 Apr 2021 05:16:39 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4669 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lc2mk-0003kd-G1; Thu, 29 Apr 2021 05:16:38 -0400 Date: Thu, 29 Apr 2021 12:16:27 +0300 Message-Id: <83o8dxe9hw.fsf@gnu.org> From: Eli Zaretskii To: Tino Calancha In-Reply-To: <87h7jq1a0i.fsf@gmail.com> (message from Tino Calancha on Wed, 28 Apr 2021 21:31:25 +0200) Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> <87tunvnxfo.fsf@linkov.net> <87h7jq1a0i.fsf@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 46374 Cc: uyennhi.qm@gmail.com, 46374@debbugs.gnu.org, monnier@iro.umontreal.ca, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Tino Calancha > Date: Wed, 28 Apr 2021 21:31:25 +0200 > Cc: 46374@debbugs.gnu.org, Stefan Monnier , > Quách Mỹ Uyên Nhi > > > Juri Linkov writes: > > +(defcustom save-some-buffers-default-predicate save-some-buffers-default-fun > + "Generator function of the default predicate for `save-some-buffers'. > + > +It must be a function with no arguments that returns a predicate. > +This predicate is called (with no parameters) from the buffer to be > +saved. Reading this, I'm confused: a function that returns a predicate? If this is literally so, why do we need this two-step approach? why not have the value _be_ a predicate function? From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 29 05:17:49 2021 Received: (at 46374) by debbugs.gnu.org; 29 Apr 2021 09:17:49 +0000 Received: from localhost ([127.0.0.1]:54831 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lc2nt-0006EM-EP for submit@debbugs.gnu.org; Thu, 29 Apr 2021 05:17:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51718) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lc2nr-0006E9-TR for 46374@debbugs.gnu.org; Thu, 29 Apr 2021 05:17:48 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:38905) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lc2nm-00035Z-Bl; Thu, 29 Apr 2021 05:17:42 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4757 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lc2nj-0003pK-T0; Thu, 29 Apr 2021 05:17:40 -0400 Date: Thu, 29 Apr 2021 12:17:31 +0300 Message-Id: <83mtthe9g4.fsf@gnu.org> From: Eli Zaretskii To: Tino Calancha In-Reply-To: <87eeeu172h.fsf@gmail.com> (message from Tino Calancha on Wed, 28 Apr 2021 22:35:02 +0200) Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> <87tunvnxfo.fsf@linkov.net> <87h7jq1a0i.fsf@gmail.com> <87zgxigpbc.fsf@mail.linkov.net> <87eeeu172h.fsf@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 46374 Cc: uyennhi.qm@gmail.com, 46374@debbugs.gnu.org, monnier@iro.umontreal.ca, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Tino Calancha > Date: Wed, 28 Apr 2021 22:35:02 +0200 > Cc: 46374@debbugs.gnu.org, Stefan Monnier , > Quách Mỹ Uyên Nhi > > > Juri Linkov writes: > > > (defun save-some-buffers-fun () > > (funcall save-some-buffers-default-predicate)) > > > > I see a problem in save-some-buffers-fun: what if > > save-some-buffers-default-predicate is still customized to nil? > I assumed we were OK with the backward incompatible change; I mean, > with requiring from now on `save-some-buffers-default-predicate' > to be a function generating the predicate. No, we always prefer backward-compatible changes where it is practical. From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 29 12:31:12 2021 Received: (at 46374) by debbugs.gnu.org; 29 Apr 2021 16:31:12 +0000 Received: from localhost ([127.0.0.1]:56684 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lc9ZI-00030S-3i for submit@debbugs.gnu.org; Thu, 29 Apr 2021 12:31:12 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:53535) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lc9ZF-00030B-4M for 46374@debbugs.gnu.org; Thu, 29 Apr 2021 12:31:10 -0400 X-Originating-IP: 91.129.102.166 Received: from mail.gandi.net (m91-129-102-166.cust.tele2.ee [91.129.102.166]) (Authenticated sender: juri@linkov.net) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id A40F42000A; Thu, 29 Apr 2021 16:31:00 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> <87tunvnxfo.fsf@linkov.net> <87h7jq1a0i.fsf@gmail.com> <87zgxigpbc.fsf@mail.linkov.net> <87eeeu172h.fsf@gmail.com> Date: Thu, 29 Apr 2021 19:04:49 +0300 In-Reply-To: <87eeeu172h.fsf@gmail.com> (Tino Calancha's message of "Wed, 28 Apr 2021 22:35:02 +0200") Message-ID: <87k0olcjnu.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> I see a problem in save-some-buffers-fun: what if >> save-some-buffers-default-predicate is still customized to nil? > I assumed we were OK with the backward incompatible change; I mean, > with requiring from now on `save-some-buffers-default-predicate' > to be a function generating the predicate. > >> 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. > We can do that; but it seems to me that the spirit of the FIXME comment > is in the line to not accept `nil' as a valid value, just functions. Indeed, to remove the FIXME comment we could set the default value to 'ignore' that returns nil: (funcall (lambda () nil)) => nil (funcall 'ignore) => nil But also it's easy to support the old value 'nil', and also support old functions that don't return a predicate. You can just return the same value if it's not a function, and also return the function if it doesn't return a predicate. Something like this (untested): (defun save-some-buffers-fun () (if (functionp save-some-buffers-default-predicate) (let ((ret (funcall save-some-buffers-default-predicate))) (if (functionp ret) ret save-some-buffers-default-predicate)) save-some-buffers-default-predicate)) From debbugs-submit-bounces@debbugs.gnu.org Tue May 18 13:46:27 2021 Received: (at 46374) by debbugs.gnu.org; 18 May 2021 17:46:27 +0000 Received: from localhost ([127.0.0.1]:57211 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lj3nX-0000RW-I6 for submit@debbugs.gnu.org; Tue, 18 May 2021 13:46:27 -0400 Received: from mail-wm1-f54.google.com ([209.85.128.54]:55258) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lj3nV-0000RJ-Ot for 46374@debbugs.gnu.org; Tue, 18 May 2021 13:46:27 -0400 Received: by mail-wm1-f54.google.com with SMTP id o127so5874494wmo.4 for <46374@debbugs.gnu.org>; Tue, 18 May 2021 10:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=QRB+exUDkevXSf7JHxGnRECa1YcEnMwWsbdvDq7JKkQ=; b=TYASLxGwO4xpTbkwXhs8+a5d1GnLJpHcCWpi9CRPl2jEsEUvJ9jbB+No9uHVFkWg0s 67MWE2XuvSzi2Y/SdI3SFRaejJr7nkEIw37RmfX3U4vU97kYsPrZZdWvud6bVHPWoALA 8YAzM4E8UevxBPFHiRFCN8mse7cmaIi4VQzfadhkJ+SzrSjS4eHntI9LkfOKV7xqzwRt jP+1VhK+Y2KcoiJgua6+E+F7nIjA4srETBV/nXqnOCBaB961gYgMiDRa5s3iXOyho3fJ qTsfg4DFiHEsMK+WKxVvdLccovWgJFZ05GulZKP3RFTfBQ17x6Cp6Nbqb/mdO0o88jfr NKXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=QRB+exUDkevXSf7JHxGnRECa1YcEnMwWsbdvDq7JKkQ=; b=VoUYSRimvgZN60LAGhXV6TFxa60IbnykcxGFX1QLYuFkZ93JnBve8IdlpHR5RuT8xS oS7uuPyCaQ/TGXf4YCkrvpSz5KfsOpncJJgzhj1lkBAyoy1Qi4pWPlUo+m1Sdl72zQek ZKLyySPRbxlbN6LpmshPVysWxEsVCUylr1qt4E/zoDTpYSS7fAhS2OF3xcy/+mcpxJ1g 8OkvD8/TYC+q7BFEDojcVEbemeUy5OA1NP6k82tYueTB235U8nXraRrzlJlz4OoNIYQI FMNaxl+ETPVZfvwYlP8DaMRkg7eVfyeyRYzx7EWlNAhynbHmN4ZiCOQKE81ipQqm1JjS zktQ== X-Gm-Message-State: AOAM533Q32JwNM0+oI/F2AyrhRX9FNAhTroikUJ+QnjARJi4QjLv1oEy sH3GxTTQvhJtU45wvBGv4fQ= X-Google-Smtp-Source: ABdhPJz73bPwxsUaP0fjdeshrc/kaQ6abmvYMP+YzB4CCA+2NOZDhvfg/ytFYcbcr1iPkF/kgFcgeQ== X-Received: by 2002:a1c:b003:: with SMTP id z3mr6318019wme.7.1621359979956; Tue, 18 May 2021 10:46:19 -0700 (PDT) Received: from [10.200.2.6] ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id f8sm17411680wmg.43.2021.05.18.10.46.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 10:46:19 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Tue, 18 May 2021 19:46:15 +0200 (CEST) To: Eli Zaretskii Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir In-Reply-To: <83mtthe9g4.fsf@gnu.org> Message-ID: <544081e2-9e2-d390-c165-fc224581956b@gmail.com> References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> <87tunvnxfo.fsf@linkov.net> <87h7jq1a0i.fsf@gmail.com> <87zgxigpbc.fsf@mail.linkov.net> <87eeeu172h.fsf@gmail.com> <83mtthe9g4.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Spam-Score: 2.1 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On Thu, 29 Apr 2021, Eli Zaretskii wrote: >>> (defun save-some-buffers-fun () >>> (funcall save-some-buffers-default-predicate)) >>> >>> I see a problem in save-some-buffers-fun: what if >>> save-some-buffers-default-predicate is still custom [...] Content analysis details: (2.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tino.calancha[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.54 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.54 listed in list.dnswl.org] 2.1 MALFORMED_FREEMAIL Bad headers on message from free email service X-Debbugs-Envelope-To: 46374 Cc: uyennhi.qm@gmail.com, juri@linkov.net, 46374@debbugs.gnu.org, monnier@iro.umontreal.ca, Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Thu, 29 Apr 2021, Eli Zaretskii wrote: >>> (defun save-some-buffers-fun () >>> (funcall save-some-buffers-default-predicate)) >>> >>> I see a problem in save-some-buffers-fun: what if >>> save-some-buffers-default-predicate is still customized to nil? >> I assumed we were OK with the backward incompatible change; I mean, >> with requiring from now on `save-some-buffers-default-predicate' >> to be a function generating the predicate. > > No, we always prefer backward-compatible changes where it is > practical. OK. It makes a lot of sense. From debbugs-submit-bounces@debbugs.gnu.org Tue May 18 14:04:33 2021 Received: (at 46374) by debbugs.gnu.org; 18 May 2021 18:04:33 +0000 Received: from localhost ([127.0.0.1]:57246 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lj453-0000v4-5l for submit@debbugs.gnu.org; Tue, 18 May 2021 14:04:33 -0400 Received: from mail-wr1-f47.google.com ([209.85.221.47]:44648) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lj451-0000un-AE for 46374@debbugs.gnu.org; Tue, 18 May 2021 14:04:31 -0400 Received: by mail-wr1-f47.google.com with SMTP id i17so11200830wrq.11 for <46374@debbugs.gnu.org>; Tue, 18 May 2021 11:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=zTkvHwB2UBXpEQbRzL1oqtV94tM/12ieZQve9rhyVBc=; b=drAh/yhEVJ3bjol/1fak/hrcEsYj9PadHwVANSx4iiC7GW94GGRasXdQZvA3YJu5jo Ml5OS91FtuVLrTxJcyDRcYq5sXuuq47AxczOwgO27Vk4g+KlhjMdKB1m5piGoed13JlJ VqFJE08X/nPXmI/daerJ7pftyVec5q6j9FzRt1b4mdrXHC1hXSndl2tt6NCrkJW+RPva rzVs6ikEioYCI2Lp5f0c1v0OtcxdHFvOTJgFLGXWGaDRrFBAHKIaudVknbg/BjxhPQ9U 7kPz6SxcevQYazQroLcUMkYajlZOQpDCYK1C+f2F6NadoXC3oD9DMuEcD5uS9YeGfi+3 1lGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=zTkvHwB2UBXpEQbRzL1oqtV94tM/12ieZQve9rhyVBc=; b=CvpBjLm8KgjnOBtdrOtKg9bv2CCbvcMscBcvd4ZznSotq85V4VAYSFGGCiI/5VTCtH 06wac4lDjupn5YY2zg76Ss5rycD2/q4VRwqwXotWwE6rEEHhwsil/3fQaAdh29i4BlII 30nRKpaQIby+FpQTCe48b8mwreSxhY6C2mEJgMPKVb76pNr6877Ieq6Rc89X/xI09QMO tkgWsYZRFBLZKEMI4k91O26aZPpR+9ThCuhOFbvREpT7j/svsD9xAxlZjDLisaYP6hKF ep8j1SaLclXW1JkSm7b1VAO2FCN2NRdmizjw86UG/O6Ma+/VXIFQXHyhyXXg0WlPMMbv tguw== X-Gm-Message-State: AOAM5338TYluRS/IC5s/gVUtnlQKrlM0N0JFK552UmS3SB6lBoyQvFOb wNpBEZieBznIcLVv14+cwsU= X-Google-Smtp-Source: ABdhPJwMe3UJkSIWXMB1YW3CMlmFkrBRkbpg9w0WqaHL3jgF7o5A4xegnmBd8dNnH/Usd7RUryv1vQ== X-Received: by 2002:a5d:448b:: with SMTP id j11mr8508191wrq.93.1621361065471; Tue, 18 May 2021 11:04:25 -0700 (PDT) Received: from [10.200.2.6] ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id o11sm8192875wrq.93.2021.05.18.11.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 11:04:24 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Tue, 18 May 2021 20:04:24 +0200 (CEST) To: Eli Zaretskii Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir In-Reply-To: <83o8dxe9hw.fsf@gnu.org> Message-ID: <55fbbe0-1f9-7460-c92f-bd12fbc3da97@gmail.com> References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> <87tunvnxfo.fsf@linkov.net> <87h7jq1a0i.fsf@gmail.com> <83o8dxe9hw.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="0-1086110462-1621361064=:25652" X-Spam-Score: 2.1 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On Thu, 29 Apr 2021, Eli Zaretskii wrote: >> From: Tino Calancha >> Date: Wed, 28 Apr 2021 21:31:25 +0200 >> Cc: 46374@debbugs.gnu.org, Stefan Monnier , >> Quách Mỹ Uyên Nhi >> >> >> Juri Linkov writes: >> >> +(defcustom save-some- [...] Content analysis details: (2.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tino.calancha[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.47 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.221.47 listed in list.dnswl.org] 2.1 MALFORMED_FREEMAIL Bad headers on message from free email service X-Debbugs-Envelope-To: 46374 Cc: uyennhi.qm@gmail.com, juri@linkov.net, 46374@debbugs.gnu.org, monnier@iro.umontreal.ca, Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-1086110462-1621361064=:25652 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT On Thu, 29 Apr 2021, Eli Zaretskii wrote: >> From: Tino Calancha >> Date: Wed, 28 Apr 2021 21:31:25 +0200 >> Cc: 46374@debbugs.gnu.org, Stefan Monnier , >> Quách Mỹ Uyên Nhi >> >> >> Juri Linkov writes: >> >> +(defcustom save-some-buffers-default-predicate save-some-buffers-default-fun >> + "Generator function of the default predicate for `save-some-buffers'. >> + >> +It must be a function with no arguments that returns a predicate. >> +This predicate is called (with no parameters) from the buffer to be >> +saved. > > Reading this, I'm confused: a function that returns a predicate? If > this is literally so, why do we need this two-step approach? why not > have the value _be_ a predicate function? The point of this two-step approach is to get access to the caller environment: - We have a function, generate-foo, that builds a predicate foo. - By calling generate-foo inside same-some-buffers, we build a foo with access to the enviroment, i.e. foo is a closure. That makes the trick to restrict the prompt to saving buffers only inside the current project. --0-1086110462-1621361064=:25652-- From debbugs-submit-bounces@debbugs.gnu.org Tue May 18 14:23:55 2021 Received: (at 46374) by debbugs.gnu.org; 18 May 2021 18:23:56 +0000 Received: from localhost ([127.0.0.1]:57264 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lj4Nn-0001PU-Ix for submit@debbugs.gnu.org; Tue, 18 May 2021 14:23:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52442) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lj4Ni-0001PD-9i for 46374@debbugs.gnu.org; Tue, 18 May 2021 14:23:53 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:46700) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lj4Nb-0000cF-9V; Tue, 18 May 2021 14:23:43 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1828 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj4NZ-0006bO-6P; Tue, 18 May 2021 14:23:43 -0400 Date: Tue, 18 May 2021 21:23:37 +0300 Message-Id: <83lf8brjdi.fsf@gnu.org> From: Eli Zaretskii To: Tino Calancha In-Reply-To: <55fbbe0-1f9-7460-c92f-bd12fbc3da97@gmail.com> (message from Tino Calancha on Tue, 18 May 2021 20:04:24 +0200 (CEST)) Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> <87tunvnxfo.fsf@linkov.net> <87h7jq1a0i.fsf@gmail.com> <83o8dxe9hw.fsf@gnu.org> <55fbbe0-1f9-7460-c92f-bd12fbc3da97@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 46374 Cc: uyennhi.qm@gmail.com, 46374@debbugs.gnu.org, monnier@iro.umontreal.ca, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Tino Calancha > Date: Tue, 18 May 2021 20:04:24 +0200 (CEST) > cc: Tino Calancha , juri@linkov.net, > 46374@debbugs.gnu.org, monnier@iro.umontreal.ca, uyennhi.qm@gmail.com > > On Thu, 29 Apr 2021, Eli Zaretskii wrote: > > >> From: Tino Calancha > >> Date: Wed, 28 Apr 2021 21:31:25 +0200 > >> Cc: 46374@debbugs.gnu.org, Stefan Monnier , > >> Quách Mỹ Uyên Nhi > >> > >> > >> Juri Linkov writes: > >> > >> +(defcustom save-some-buffers-default-predicate save-some-buffers-default-fun > >> + "Generator function of the default predicate for `save-some-buffers'. > >> + > >> +It must be a function with no arguments that returns a predicate. > >> +This predicate is called (with no parameters) from the buffer to be > >> +saved. > > > > Reading this, I'm confused: a function that returns a predicate? If > > this is literally so, why do we need this two-step approach? why not > > have the value _be_ a predicate function? > > The point of this two-step approach is to get access to the caller > environment: > > - We have a function, generate-foo, that builds a predicate foo. > - By calling generate-foo inside same-some-buffers, we build a foo with > access to the enviroment, i.e. foo is a closure. > > That makes the trick to restrict the prompt to saving buffers only inside > the current project. IMNSHO, this is not a very good idea for a defcustom. What user will be able to provide such a function willy-nilly? From debbugs-submit-bounces@debbugs.gnu.org Tue May 18 14:47:51 2021 Received: (at 46374) by debbugs.gnu.org; 18 May 2021 18:47:51 +0000 Received: from localhost ([127.0.0.1]:57305 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lj4kx-0004Bi-28 for submit@debbugs.gnu.org; Tue, 18 May 2021 14:47:51 -0400 Received: from mail-wm1-f52.google.com ([209.85.128.52]:37549) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lj4kv-0004BT-AP for 46374@debbugs.gnu.org; Tue, 18 May 2021 14:47:50 -0400 Received: by mail-wm1-f52.google.com with SMTP id f19-20020a05600c1553b02901794fafcfefso1461300wmg.2 for <46374@debbugs.gnu.org>; Tue, 18 May 2021 11:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=qDnQuo0BMTntVadOA0tdtGOjApZ/y6TZb7KXsC8g2bM=; b=a1DBC80C/fdT2w1PwXwZm1Wn8I2jscssLeRm2sfl/Zwrll6hFZ2zQnaoRLcfzirXSt DgzZnCu6lWnITaWNIPQTemdd0K+GGhi9G99tXvEMI2oC3KgEa860jGN47QWDKpHeprWH Mik5kv+DRxe2LkLVeh2LmK8tl4sQiTINiNCt5dazR9SsASuEluK25MbJnt/HCphIYVIh +LOfhb+vwTvupw2IjztnkhJTT6cOSIVaDF+eT+X3VpXfwxZae1MN6VnhO2ZGE1knFYAd gfrM2qyWdIdFnrxMHMaRezPelaaqE9yiaKF9T4GWTx/cGcHApepNnwQswrCyf/sxzLNO Cdjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=qDnQuo0BMTntVadOA0tdtGOjApZ/y6TZb7KXsC8g2bM=; b=kSD+Yj6nv++po9qXQy6izuI1vKWfxTsYfCZUMy+BWTGp/BdHkgYaCWgEdTXU5ffJeB ZcL3wF0gQkcUGB17bZjogcrQTil7OABvuGou3YO1BV6J/XSnElTvkVJzcjuXD4nxJ3fn 1/7hDzUoLI00FE9eTWQ1IqyEM7i+g1sjL84BrwQcwdmsThrqy93UFyaGbyijLg/uxPN6 IfcEV2DN0SEvs/r8nUT1vZiANYS3o6sVfXcDICeXZbICP2n9QfPYQi26FxsCY9azh17D V+uQ4mQ0po1IPN8lW5CBSQyZGfZDE6Tm8iW04BPmJb6a4QaY7auNw3uDXM1DnlXwslWa nVmQ== X-Gm-Message-State: AOAM533VXLHeDXZXLjHM4oV1MfXSovOXL4GtaT7y8P736QKs4rRzNyJT STDpO+yQMPLjXfQAkK9z1AU= X-Google-Smtp-Source: ABdhPJzzYfW5G1ufywW2XSyAl3RStyG6RXw9b7/9/DDNb8rAoQ69ecNWIgOOYrMIFohN7KcqyyKv7w== X-Received: by 2002:a05:600c:49a2:: with SMTP id h34mr6496589wmp.64.1621363663392; Tue, 18 May 2021 11:47:43 -0700 (PDT) Received: from [10.200.2.6] ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id x11sm22090228wrl.13.2021.05.18.11.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 11:47:42 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Tue, 18 May 2021 20:47:42 +0200 (CEST) To: Eli Zaretskii Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir In-Reply-To: <83lf8brjdi.fsf@gnu.org> Message-ID: References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> <87tunvnxfo.fsf@linkov.net> <87h7jq1a0i.fsf@gmail.com> <83o8dxe9hw.fsf@gnu.org> <55fbbe0-1f9-7460-c92f-bd12fbc3da97@gmail.com> <83lf8brjdi.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Spam-Score: 2.1 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On Tue, 18 May 2021, Eli Zaretskii wrote: >> - We have a function, generate-foo, that builds a predicate foo. >> - By calling generate-foo inside same-some-buffers, we build a foo with >> access to the enviroment, i.e. foo is a closure. >> >> [...] Content analysis details: (2.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tino.calancha[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.52 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.52 listed in wl.mailspike.net] 2.1 MALFORMED_FREEMAIL Bad headers on message from free email service X-Debbugs-Envelope-To: 46374 Cc: uyennhi.qm@gmail.com, juri@linkov.net, 46374@debbugs.gnu.org, monnier@iro.umontreal.ca, Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Tue, 18 May 2021, Eli Zaretskii wrote: >> - We have a function, generate-foo, that builds a predicate foo. >> - By calling generate-foo inside same-some-buffers, we build a foo with >> access to the enviroment, i.e. foo is a closure. >> >> That makes the trick to restrict the prompt to saving buffers only inside >> the current project. > > IMNSHO, this is not a very good idea for a defcustom. What user will > be able to provide such a function willy-nilly? Yeah, I agree that's not easy to wrote; that's why Juri suggested me to provide sensible options for this defcustom. If you check the code that Juri embeded few emails before this one, you see that users can control the behaviour with the customization UI. In the future, we could extend those defaults if we find other useful behaviors. From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 13 03:14:31 2021 Received: (at 46374) by debbugs.gnu.org; 13 Aug 2021 07:14:31 +0000 Received: from localhost ([127.0.0.1]:40415 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mEROh-0007zG-B5 for submit@debbugs.gnu.org; Fri, 13 Aug 2021 03:14:31 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:64443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mEROf-0007yi-Nu; Fri, 13 Aug 2021 03:14:30 -0400 Received: (Authenticated sender: juri@linkov.net) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id ADC5640007; Fri, 13 Aug 2021 07:14:21 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> <87tunvnxfo.fsf@linkov.net> <87h7jq1a0i.fsf@gmail.com> <87zgxigpbc.fsf@mail.linkov.net> <87eeeu172h.fsf@gmail.com> <87k0olcjnu.fsf@mail.linkov.net> <82abe5b9-7d42-b05d-26a5-fd63e1f59e3a@gmail.com> Date: Fri, 13 Aug 2021 10:11:34 +0300 In-Reply-To: <82abe5b9-7d42-b05d-26a5-fd63e1f59e3a@gmail.com> (Tino Calancha's message of "Tue, 18 May 2021 20:56:28 +0200 (CEST)") Message-ID: <87y295ddjt.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) tags 46374 fixed close 46374 28.0.50 thanks Thanks for this useful feature. It was requested yesterday in bug#49980. So now it's pushed to master and closed. >> Indeed, to remove the FIXME comment we could set the default value to >> 'ignore' that returns nil: >> >> (funcall (lambda () nil)) => nil >> (funcall 'ignore) => nil > > Opps, This is a pitfall: the second one will do exactly the opposite that > the first one does :-) > No problem! We can apply Bon Jovi! > > (funcall (lambda () nil)) => nil > (funcall 'always) => t > > [the above are equivalent; yeah, it sounds impossible, but if you read the > code you will understand why] > >> But also it's easy to support the old value 'nil', and also >> support old functions that don't return a predicate. >> You can just return the same value if it's not a function, >> and also return the function if it doesn't return a predicate. >> Something like this (untested): >> >> (defun save-some-buffers-fun () >> (if (functionp save-some-buffers-default-predicate) >> (let ((ret (funcall save-some-buffers-default-predicate))) >> (if (functionp ret) ret save-some-buffers-default-predicate)) >> save-some-buffers-default-predicate)) > > Neat! > I am going to use this version for a while in my machine, to give it more > testing. > Thank you. From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 13 12:11:31 2021 Received: (at 46374) by debbugs.gnu.org; 13 Aug 2021 16:11:31 +0000 Received: from localhost ([127.0.0.1]:42982 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mEZmN-0006hp-CN for submit@debbugs.gnu.org; Fri, 13 Aug 2021 12:11:31 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:35301) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mEZmK-0006hI-8b for 46374@debbugs.gnu.org; Fri, 13 Aug 2021 12:11:30 -0400 Received: (Authenticated sender: juri@linkov.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 81C4960004; Fri, 13 Aug 2021 16:11:20 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@gmail.com> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> <87tunvnxfo.fsf@linkov.net> <87h7jq1a0i.fsf@gmail.com> <87zgxigpbc.fsf@mail.linkov.net> <87eeeu172h.fsf@gmail.com> <87k0olcjnu.fsf@mail.linkov.net> <82abe5b9-7d42-b05d-26a5-fd63e1f59e3a@gmail.com> <87y295ddjt.fsf@mail.linkov.net> <3c7dc42a-e484-8068-d28d-49677f0b4a7@gmail.com> Date: Fri, 13 Aug 2021 19:08:15 +0300 In-Reply-To: <3c7dc42a-e484-8068-d28d-49677f0b4a7@gmail.com> (Tino Calancha's message of "Fri, 13 Aug 2021 10:45:05 +0200 (CEST)") Message-ID: <87a6llba4w.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , =?utf-8?B?UXXDoWNoIE3hu7kgVXnDqm4gTmhp?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > I might apply some addition changes. > I've been months testing the feature every day (and evry happy with it); > but I solved a small issue about 1 month ago (I didn't mentioned it here). > > Since I will start vacation tomorrow, I will have time to add my > minor tweaks. > > I also want to add some unit tests. You are welcome to improve this feature when you want. Enjoy your time. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 29 08:51:36 2021 Received: (at 46374) by debbugs.gnu.org; 29 Aug 2021 12:51:36 +0000 Received: from localhost ([127.0.0.1]:55734 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKKHf-0001Qj-FC for submit@debbugs.gnu.org; Sun, 29 Aug 2021 08:51:36 -0400 Received: from helin.uberspace.de ([185.26.156.195]:60968) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKI7x-0008Ip-Bw for 46374@debbugs.gnu.org; Sun, 29 Aug 2021 06:33:26 -0400 Received: (qmail 26605 invoked from network); 29 Aug 2021 10:33:23 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by helin.uberspace.de with SMTP; 29 Aug 2021 10:33:23 -0000 User-agent: mu4e 1.6.3; emacs 28.0.50 From: Hauke Rehfeld To: 46374@debbugs.gnu.org Subject: Regression: erronous calls to PRED switch major-mode of unrelated modified buffers Date: Sat, 28 Aug 2021 18:25:23 +0200 Message-ID: <87r1ecilqn.fsf@haukerehfeld.de> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 46374 X-Mailman-Approved-At: Sun, 29 Aug 2021 08:51:34 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.2 (/) Hmmm, I'm pretty sure the changes to `save-some-buffers` here regarding the predicate indirection caused a regression and/or very unexpected behavior that causes bugs in previously working code. Consider `(save-some-buffers t (lambda () (derived-mode-p 'org-mode)))' called from an org-mode buffer. It runs through the part of `save-some-buffers' that is trying to resolve the PRED indirection: https://github.com/emacs-mirror/emacs/blob/692da8c6a82f8de376a2eec9304773b3e85205f3/lisp/files.el#L5792 ``` emacs-lisp ;; 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))) ``` which evaluates the predicate to check if it returns a function -- which `(derived-mode-p)' does, as it simply returns the major-mode symbol on success! In this case, it would be `#'org-mode'. So then `org-mode' is called on any unsaved buffers as a PREDICATE, switching those buffers to org-mode. Compare this usage in org-mode, org.el:15357: ``` emacs-lisp (defun org-save-all-org-buffers () "Save all Org buffers without user confirmation." (interactive) (message "Saving all Org buffers...") (save-some-buffers t (lambda () (derived-mode-p 'org-mode))) (when (featurep 'org-id) (org-id-locations-save)) (message "Saving all Org buffers... done")) ``` From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 29 12:55:14 2021 Received: (at 46374) by debbugs.gnu.org; 29 Aug 2021 16:55:14 +0000 Received: from localhost ([127.0.0.1]:57273 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKO5R-0003Pd-TE for submit@debbugs.gnu.org; Sun, 29 Aug 2021 12:55:14 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:58009) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKO5M-0003Ox-Ey for 46374@debbugs.gnu.org; Sun, 29 Aug 2021 12:55:09 -0400 Received: (Authenticated sender: juri@linkov.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 0699B240003; Sun, 29 Aug 2021 16:54:59 +0000 (UTC) From: Juri Linkov To: Hauke Rehfeld Subject: Re: bug#46374: Regression: erronous calls to PRED switch major-mode of unrelated modified buffers Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87r1ecilqn.fsf@haukerehfeld.de> Date: Sun, 29 Aug 2021 19:38:20 +0300 In-Reply-To: <87r1ecilqn.fsf@haukerehfeld.de> (Hauke Rehfeld's message of "Sat, 28 Aug 2021 18:25:23 +0200") Message-ID: <87a6l0cjyj.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > Hmmm, I'm pretty sure the changes to `save-some-buffers` here > regarding the predicate indirection caused a regression and/or > very unexpected behavior that causes bugs in previously working > code. Thanks, this is a very interesting case, so Cc'ing Stefan and Tino. > Consider > > `(save-some-buffers t (lambda () (derived-mode-p 'org-mode)))' > > called from an org-mode buffer. It runs through the part of > `save-some-buffers' that is trying to resolve the PRED > indirection: > > ``` emacs-lisp > ;; 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))) > ``` > which evaluates the predicate to check if it returns a function -- > which `(derived-mode-p)' does, as it simply returns the major-mode > symbol on success! In this case, it would be `#'org-mode'. So then > `org-mode' is called on any unsaved buffers as a PREDICATE, > switching those buffers to org-mode. Indeed, the predicate returns a function, just to add more fun: (funcall (lambda () (derived-mode-p 'lisp-interaction-mode))) => lisp-interaction-mode This means we need to invent some ad-hoc format to distinguish between these cases. For example, to create a lexically-bound predicate at the beginning, it could be called with e.g. (save-some-buffers t '(eval . save-some-buffers-root)) and defcustom will look like: (defcustom save-some-buffers-default-predicate nil :type '(choice (const :tag "Default" nil) (function :tag "Only in subdirs of root" (eval . save-some-buffers-root)) (function :tag "Custom function")) Quite ugly, but I see no more natural way. From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 30 03:41:21 2021 Received: (at 46374) by debbugs.gnu.org; 30 Aug 2021 07:41:21 +0000 Received: from localhost ([127.0.0.1]:58015 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKbuz-0000RX-J5 for submit@debbugs.gnu.org; Mon, 30 Aug 2021 03:41:21 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:58425) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKbux-0000RE-UZ for 46374@debbugs.gnu.org; Mon, 30 Aug 2021 03:41:20 -0400 Received: (Authenticated sender: juri@linkov.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id B5DD11BF204; Mon, 30 Aug 2021 07:41:11 +0000 (UTC) From: Juri Linkov To: Hauke Rehfeld Subject: Re: bug#46374: Regression: erronous calls to PRED switch major-mode of unrelated modified buffers Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87r1ecilqn.fsf@haukerehfeld.de> <87a6l0cjyj.fsf@mail.linkov.net> Date: Mon, 30 Aug 2021 10:28:36 +0300 In-Reply-To: <87a6l0cjyj.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 29 Aug 2021 19:38:20 +0300") Message-ID: <87bl5f1lbn.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > This means we need to invent some ad-hoc format to distinguish between > these cases. For example, to create a lexically-bound predicate > at the beginning, it could be called with e.g. > > (save-some-buffers t '(eval . save-some-buffers-root)) > > and defcustom will look like: > > (defcustom save-some-buffers-default-predicate nil > :type '(choice (const :tag "Default" nil) > (function :tag "Only in subdirs of root" > (eval . save-some-buffers-root)) > (function :tag "Custom function")) Or maybe simply '(save-some-buffers-root): (defcustom save-some-buffers-default-predicate nil :type '(choice (const :tag "Default" nil) (function :tag "Only in subdirs of root" (save-some-buffers-root)) Then the following two calls both will have exactly the same effect: (save-some-buffers t '(save-some-buffers-root)) (save-some-buffers t (save-some-buffers-root)) From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 30 10:56:48 2021 Received: (at 46374) by debbugs.gnu.org; 30 Aug 2021 14:56:48 +0000 Received: from localhost ([127.0.0.1]:59965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKiiL-00077z-BO for submit@debbugs.gnu.org; Mon, 30 Aug 2021 10:56:48 -0400 Received: from helin.uberspace.de ([185.26.156.195]:47458) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKfjc-0000ks-5e for 46374@debbugs.gnu.org; Mon, 30 Aug 2021 07:45:52 -0400 Received: (qmail 4423 invoked from network); 30 Aug 2021 11:45:49 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by helin.uberspace.de with SMTP; 30 Aug 2021 11:45:49 -0000 References: <878s7z4ihk.fsf@gmail.com> <87r1ecilqn.fsf@haukerehfeld.de> <87a6l0cjyj.fsf@mail.linkov.net> <87bl5f1lbn.fsf@mail.linkov.net> User-agent: mu4e 1.6.3; emacs 28.0.50 From: Hauke Rehfeld To: Juri Linkov Subject: Re: bug#46374: Regression: erronous calls to PRED switch major-mode of unrelated modified buffers Date: Mon, 30 Aug 2021 13:43:23 +0200 In-reply-to: <87bl5f1lbn.fsf@mail.linkov.net> Message-ID: <87v93ncg0n.fsf@haukerehfeld.de> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 46374 X-Mailman-Approved-At: Mon, 30 Aug 2021 10:56:44 -0400 Cc: 46374@debbugs.gnu.org, Stefan Monnier , Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) I'm way not deep enough into this issue, but how about using a temp buffer and checking for major mode equivalent (can pred ever reasonably be fundamental-mode?): ;; 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)))) ;; don't use the result of `pred' if it returns the current buffer major-mode (with-temp-buffer (let ((pred-fun (funcall pred))) (when (and (functionp pred-fun) (not (eq major-mode pred-fun))) (setq pred pred-fun))))) Juri Linkov writes: >> This means we need to invent some ad-hoc format to distinguish >> between >> these cases. For example, to create a lexically-bound >> predicate >> at the beginning, it could be called with e.g. >> >> (save-some-buffers t '(eval . save-some-buffers-root)) >> >> and defcustom will look like: >> >> (defcustom save-some-buffers-default-predicate nil >> :type '(choice (const :tag "Default" nil) >> (function :tag "Only in subdirs of root" >> (eval . save-some-buffers-root)) >> (function :tag "Custom function")) > > Or maybe simply '(save-some-buffers-root): > > (defcustom save-some-buffers-default-predicate nil > :type '(choice (const :tag "Default" nil) > (function :tag "Only in subdirs of root" > (save-some-buffers-root)) > > Then the following two calls both will have exactly the same > effect: > > (save-some-buffers t '(save-some-buffers-root)) > (save-some-buffers t (save-some-buffers-root)) From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 30 12:06:07 2021 Received: (at 46374) by debbugs.gnu.org; 30 Aug 2021 16:06:08 +0000 Received: from localhost ([127.0.0.1]:60029 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKjnP-0000mv-OQ for submit@debbugs.gnu.org; Mon, 30 Aug 2021 12:06:07 -0400 Received: from helin.uberspace.de ([185.26.156.195]:45596) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKjnK-0000mJ-4T for 46374@debbugs.gnu.org; Mon, 30 Aug 2021 12:06:02 -0400 Received: (qmail 1959 invoked from network); 30 Aug 2021 16:05:55 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by helin.uberspace.de with SMTP; 30 Aug 2021 16:05:55 -0000 References: <878s7z4ihk.fsf@gmail.com> <87r1ecilqn.fsf@haukerehfeld.de> <87a6l0cjyj.fsf@mail.linkov.net> <87bl5f1lbn.fsf@mail.linkov.net> <87v93ncg0n.fsf@haukerehfeld.de> User-agent: mu4e 1.6.3; emacs 28.0.50 From: Hauke Rehfeld To: Juri Linkov Subject: Re: bug#46374: Regression: erronous calls to PRED switch major-mode of unrelated modified buffers Date: Mon, 30 Aug 2021 18:04:31 +0200 In-reply-to: <87v93ncg0n.fsf@haukerehfeld.de> Message-ID: <87sfyqdijl.fsf@haukerehfeld.de> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Sorry, that was broken when called with an empty `pred' argument. This should work (but testing all code paths is indeed not a simple task): ;; Allow `pred' to be a function that returns a predicate ;; with lexical bindings in its original environment (bug#46374). (when (functionp pred) ;; don't use the result of `pred' if it returns the current buffer major-mode (with-temp-buffer (let ((pred-fun (funcall pred))) (when (and (functionp pred-fun) (not (eq major-mode pred-fun))) (setq pred pred-fun))))) Hauke Rehfeld writes: > I'm way not deep enough into this issue, but how about using a > temp buffer and checking for major mode equivalent (can pred > ever > reasonably be fundamental-mode?): > > ;; 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)))) > ;; don't use the result of `pred' if it returns the current > buffer major-mode > (with-temp-buffer > (let ((pred-fun (funcall pred))) > (when (and (functionp pred-fun) (not (eq major-mode > pred-fun))) > (setq pred pred-fun))))) > > > Juri Linkov writes: > >>> This means we need to invent some ad-hoc format to distinguish >>> between >>> these cases. For example, to create a lexically-bound >>> predicate >>> at the beginning, it could be called with e.g. >>> >>> (save-some-buffers t '(eval . save-some-buffers-root)) >>> >>> and defcustom will look like: >>> >>> (defcustom save-some-buffers-default-predicate nil >>> :type '(choice (const :tag "Default" nil) >>> (function :tag "Only in subdirs of root" >>> (eval . save-some-buffers-root)) >>> (function :tag "Custom function")) >> >> Or maybe simply '(save-some-buffers-root): >> >> (defcustom save-some-buffers-default-predicate nil >> :type '(choice (const :tag "Default" nil) >> (function :tag "Only in subdirs of root" >> (save-some-buffers-root)) >> >> Then the following two calls both will have exactly the same >> effect: >> >> (save-some-buffers t '(save-some-buffers-root)) >> (save-some-buffers t (save-some-buffers-root)) From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 31 03:11:12 2021 Received: (at 46374) by debbugs.gnu.org; 31 Aug 2021 07:11:12 +0000 Received: from localhost ([127.0.0.1]:32785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKxvM-0004pY-7P for submit@debbugs.gnu.org; Tue, 31 Aug 2021 03:11:12 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:43383) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKxvH-0004ob-4c for 46374@debbugs.gnu.org; Tue, 31 Aug 2021 03:11:07 -0400 Received: (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id C04F8FF802; Tue, 31 Aug 2021 07:10:58 +0000 (UTC) From: Juri Linkov To: Hauke Rehfeld Subject: Re: bug#46374: Regression: erronous calls to PRED switch major-mode of unrelated modified buffers Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87r1ecilqn.fsf@haukerehfeld.de> <87a6l0cjyj.fsf@mail.linkov.net> <87bl5f1lbn.fsf@mail.linkov.net> <87v93ncg0n.fsf@haukerehfeld.de> Date: Tue, 31 Aug 2021 10:02:42 +0300 In-Reply-To: <87v93ncg0n.fsf@haukerehfeld.de> (Hauke Rehfeld's message of "Mon, 30 Aug 2021 13:43:23 +0200") Message-ID: <87bl5e85bh.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Stefan Monnier , Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > I'm way not deep enough into this issue, but how about using a > temp buffer and checking for major mode equivalent (can pred ever > reasonably be fundamental-mode?): This assumes that only derived-mode-p can be used as the predicate, so it will fix only this particular case until some other code will find a more clever way to circumvent this assumption by returning some other arbitrary function that does more nasty things than changing the major mode. From unknown Sat Aug 16 21:18:13 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug No longer marked as fixed in versions 28.0.50 and reopened. Date: Sun, 05 Sep 2021 08:12:02 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug No longer marked as fixed in versions 28.0.50 and reopened. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 05 04:11:03 2021 Received: (at control) by debbugs.gnu.org; 5 Sep 2021 08:11:03 +0000 Received: from localhost ([127.0.0.1]:49124 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMnF1-0007Lb-8Z for submit@debbugs.gnu.org; Sun, 05 Sep 2021 04:11:03 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:32991) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMnEz-0007Kr-Gi; Sun, 05 Sep 2021 04:11:02 -0400 Received: (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 2E99EFF802; Sun, 5 Sep 2021 08:10:53 +0000 (UTC) From: Juri Linkov To: Stefan Kangas Subject: Re: bug#50380: Hard to understand NEWS entry about 'save-some-buffers-default-predicate' Organization: LINKOV.NET References: <87zgssjh2v.fsf@mail.linkov.net> Date: Sun, 05 Sep 2021 11:05:41 +0300 In-Reply-To: (Stefan Kangas's message of "Sat, 4 Sep 2021 22:01:18 +0200") Message-ID: <87tuizv44q.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: control Cc: 50380@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) reopen 46374 forcemerge 46374 50380 thanks >> There is still open bug#46374 that requires rewriting this feature anyway. > > That bug is closed though, should it be re-opened? Should this bug be > merged into that one? (I only skimmed it very briefly.) That's right, now re-opened and merged. From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 05 06:09:35 2021 Received: (at 46374) by debbugs.gnu.org; 5 Sep 2021 10:09:35 +0000 Received: from localhost ([127.0.0.1]:49311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMp5j-0006Xg-Jz for submit@debbugs.gnu.org; Sun, 05 Sep 2021 06:09:35 -0400 Received: from mail-wr1-f41.google.com ([209.85.221.41]:34776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMp5h-0006XP-Sk for 46374@debbugs.gnu.org; Sun, 05 Sep 2021 06:09:34 -0400 Received: by mail-wr1-f41.google.com with SMTP id m9so5201312wrb.1 for <46374@debbugs.gnu.org>; Sun, 05 Sep 2021 03:09:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=G2lhCLdVzrwHaV204jJuK6OBpRIYDmJw4Xl3Zcg8nZU=; b=T+E+NAsx4mNLtDYwnxXWsb8SryaJyCIT8KUJPoUqCacfw8+eTgKBbTjZ3F4LxXtfqQ WtuQtPRngGKo07QdPM1KrNp/3Ppmfo1Oll2yP9t3MT+IbPCJF7gp75GJ6HI17MojK8L/ I0azGERIHHKKRePBVUnhz26u1RwXjEjpfgV9G8kjvsYT9GpkTqZ2wC0/7kKjraP1LSGx 2JIdCv1x4GHZXMCe0/Dg9e+5U2+qclS22blxZmoq8Ehw6HUDZiTCsyBKvzNbupXkliue agciqpOqTrXJOtVNLT9IGYOnFp2DufuOf2JPTRNxu1hwE9KP8nyrlI6uik4PbuAFZe6g u72Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=G2lhCLdVzrwHaV204jJuK6OBpRIYDmJw4Xl3Zcg8nZU=; b=BqN4jypiydoDUl2dgTCT+arCpKxiq5TMuG5UY9r628ALkXe52tsmq14/p9Cs6/Dr5i owrxfMY9VAVnHkeW+ILsQMa2G86lBouS6kzvEoAqYOwRszI2VysBDZhLnQtptsxLfC6k IezSE8hwXsIAf5NGnUBqyLqdg6A9awDuDFFegclfHuGjeV30hiNjKTxyEmJjSknhVNzt W/sY0CidE2GaWA/Zc3pdrhC5jpP/Oqel5bB10TjJfSAT96YXek3pCLuvPN6PJnMxDPQ5 +vUvIXbKETDf8eTFqsKTvgH7ca6VtEOdw8fbPIbUZ6i/TcS+j28UPG5/T3hH/HgupNgm eYqw== X-Gm-Message-State: AOAM533tI7fkPlCDWQ6pQssIzzCSIH6LcfYwdHWaMn+Y5F9YOuxWVVDQ hNx1dih1i6WubUMcOLOGvVUgAMYCIYsaQQ== X-Google-Smtp-Source: ABdhPJxoOvEtpRsLOqO1hZolYR8YhgBceB6Nm2TYbpsx+Dsy822E1AWtvPmABtQZY1A9JKesJ0iEuw== X-Received: by 2002:a5d:440d:: with SMTP id z13mr8186165wrq.216.1630836568041; Sun, 05 Sep 2021 03:09:28 -0700 (PDT) Received: from localhost.example.com ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id a6sm4301849wmb.7.2021.09.05.03.09.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Sep 2021 03:09:27 -0700 (PDT) From: Tino Calancha To: Juri Linkov Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir References: <878s7z4ihk.fsf@gmail.com> <87r1ecilqn.fsf@haukerehfeld.de> <87a6l0cjyj.fsf@mail.linkov.net> <87bl5f1lbn.fsf@mail.linkov.net> Date: Sun, 05 Sep 2021 12:09:26 +0200 In-Reply-To: <87bl5f1lbn.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 30 Aug 2021 10:28:36 +0300") Message-ID: <87ilzfuyeh.fsf_-_@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Hauke Rehfeld , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Juri Linkov writes: >> This means we need to invent some ad-hoc format to distinguish between >> these cases. For example, to create a lexically-bound predicate >> at the beginning, it could be called with e.g. >> >> (save-some-buffers t '(eval . save-some-buffers-root)) >> >> and defcustom will look like: >> >> (defcustom save-some-buffers-default-predicate nil >> :type '(choice (const :tag "Default" nil) >> (function :tag "Only in subdirs of root" >> (eval . save-some-buffers-root)) >> (function :tag "Custom function")) > > Or maybe simply '(save-some-buffers-root): Hi Juri! Being able to set `save-some-buffers-root' as the value of `save-some-buffers-default-predicate' is easy for users. The problem I see is that it hides the real nature of `save-some-buffers-root': - it's not a predicate (as the docstring of `save-some-buffers-default-predicate' suggests). - it's a function generating the default predicate. We can make the distinction (default predicate <-> func generating a default predicate) more clear if we put the generating functions in a list. Then, we can restrict the allowed pred-fun to the elements inside such a list. I have played today with this quick-and-dirty patch: How do you think? --8<-----------------------------cut here---------------start------------->8--- diff --git a/lisp/files.el b/lisp/files.el index 7e4bdab507..91582ec9b0 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5731,6 +5731,13 @@ save-some-buffers-action-alist (defvar-local buffer-save-without-query nil "Non-nil means `save-some-buffers' should save this buffer without asking.") +(defvar save-some-buffers-fn-generating-pred '(save-some-buffers-root) + "List of supported functions to generate a default predicate for `save-some-buffers'. +Each element is a function with no arguments that returns a predicate +suitable for `save-some-buffers'. +You can use any of these functions as the value of +`save-some-buffers-default-predicate'.") + (defcustom save-some-buffers-default-predicate nil "Default predicate for `save-some-buffers'. @@ -5789,7 +5796,8 @@ save-some-buffers (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)))) + (let ((pred-fun (and (memq pred save-some-buffers-fn-generating-pred) + (funcall pred)))) (when (functionp pred-fun) (setq pred pred-fun))) (let* ((switched-buffer nil) --8<-----------------------------cut here---------------end--------------->8--- From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 05 12:41:54 2021 Received: (at 46374) by debbugs.gnu.org; 5 Sep 2021 16:41:54 +0000 Received: from localhost ([127.0.0.1]:50877 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMvDN-0008Dh-Oo for submit@debbugs.gnu.org; Sun, 05 Sep 2021 12:41:53 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:38639) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMvDM-0008DG-CU for 46374@debbugs.gnu.org; Sun, 05 Sep 2021 12:41:52 -0400 Received: (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 95FC4E0003; Sun, 5 Sep 2021 16:41:44 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87r1ecilqn.fsf@haukerehfeld.de> <87a6l0cjyj.fsf@mail.linkov.net> <87bl5f1lbn.fsf@mail.linkov.net> <87ilzfuyeh.fsf_-_@gmail.com> Date: Sun, 05 Sep 2021 19:21:34 +0300 In-Reply-To: <87ilzfuyeh.fsf_-_@gmail.com> (Tino Calancha's message of "Sun, 05 Sep 2021 12:09:26 +0200") Message-ID: <87h7ezw6up.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Hauke Rehfeld , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > Being able to set `save-some-buffers-root' as the value of > `save-some-buffers-default-predicate' is easy for users. > > The problem I see is that it hides the real nature of `save-some-buffers-root': > - it's not a predicate (as the docstring of `save-some-buffers-default-predicate' suggests). > - it's a function generating the default predicate. > > We can make the distinction (default predicate <-> func generating a default predicate) > more clear if we put the generating functions in a list. > > Then, we can restrict the allowed pred-fun to the elements inside such a list. > > I have played today with this quick-and-dirty patch: > How do you think? Nice idea, and it's better than what I proposed. The only change that I suggest is instead of a list, to put a special symbol on the symbol property, for example: (put 'save-some-buffers-root 'higher-order-function t) or simply (put 'save-some-buffers-root 'hof t) A better name is appreciated. From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 10 13:40:05 2021 Received: (at 46374) by debbugs.gnu.org; 10 Oct 2021 17:40:05 +0000 Received: from localhost ([127.0.0.1]:55791 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZcnq-00020K-Hq for submit@debbugs.gnu.org; Sun, 10 Oct 2021 13:40:05 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:56185) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZcnk-0001za-4s; Sun, 10 Oct 2021 13:40:00 -0400 Received: (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 2082CE0009; Sun, 10 Oct 2021 17:39:47 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir References: <878s7z4ihk.fsf@gmail.com> <87r1ecilqn.fsf@haukerehfeld.de> <87a6l0cjyj.fsf@mail.linkov.net> <87bl5f1lbn.fsf@mail.linkov.net> <87ilzfuyeh.fsf_-_@gmail.com> <87h7ezw6up.fsf@mail.linkov.net> Date: Sun, 10 Oct 2021 20:38:56 +0300 In-Reply-To: <87h7ezw6up.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 05 Sep 2021 19:21:34 +0300") Message-ID: <87sfx8aifj.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Hauke Rehfeld , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) close 46374 28.0.60 thanks >> Being able to set `save-some-buffers-root' as the value of >> `save-some-buffers-default-predicate' is easy for users. >> >> The problem I see is that it hides the real nature of `save-some-buffers-root': >> - it's not a predicate (as the docstring of `save-some-buffers-default-predicate' suggests). >> - it's a function generating the default predicate. >> >> We can make the distinction (default predicate <-> func generating a default predicate) >> more clear if we put the generating functions in a list. >> >> Then, we can restrict the allowed pred-fun to the elements inside such a list. >> >> I have played today with this quick-and-dirty patch: >> How do you think? > > Nice idea, and it's better than what I proposed. > The only change that I suggest is instead of a list, > to put a special symbol on the symbol property, > for example: > > (put 'save-some-buffers-root 'higher-order-function t) > or simply > (put 'save-some-buffers-root 'hof t) > > A better name is appreciated. I can't invent a better name than 'save-some-buffers-function'. So now pushed with this property name. From unknown Sat Aug 16 21:18:13 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 08 Nov 2021 12:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 06 12:10:43 2022 Received: (at control) by debbugs.gnu.org; 6 Jan 2022 17:10:43 +0000 Received: from localhost ([127.0.0.1]:42092 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5WHi-00083C-VC for submit@debbugs.gnu.org; Thu, 06 Jan 2022 12:10:43 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:39977) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5WHg-00082s-0l for control@debbugs.gnu.org; Thu, 06 Jan 2022 12:10:41 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 412E14420CD; Thu, 6 Jan 2022 12:10:34 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 155964420CA; Thu, 6 Jan 2022 12:10:33 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1641489033; bh=H5r/RecpfzLM8s3iN9I1tj6vx7enXkhYJygkz+tBQ1Y=; h=From:To:Subject:References:Date:In-Reply-To:From; b=Z1xg0Q7BAVv1g5qm6RysE7qPqgtK0PfAmljrIHjtvagAAgPj/CYhNf2OBrnDv+klp YoriJtH8Le+cfakoMN4yYWncn8nfPhk0befKxxvs24tlcy/E6vkn9pIb/zqSwMQtyE BbqAFL/cFamk4MZY7jLl+in+Nr3kXQ+uxMbFXZTMNNshwUGmR4Z/411HtjdIV78T99 vG9e48lnVNUUjY1gtoAIkH5NNbD0+tH1lbv7B8xk1R4lGeS3fRpxTpxGTXphtH4zdp eGn2f0AUdOW6hxWZ/BZg/MwJuluUNUglu2yy8Bshc8K+pM5H1L/TF/wZV/HkKTynSj YQ5RUFjIIJ66Q== Received: from ceviche (unknown [216.154.30.173]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id DAE0712020D; Thu, 6 Jan 2022 12:10:32 -0500 (EST) From: Stefan Monnier To: control@debbugs.gnu.org Subject: Re: Archived problem report bug#46374 (bug#46374: Regression: erronous calls to PRED switch major-mode of unrelated modified buffers) Message-ID: References: <878s7z4ihk.fsf@gmail.com> Date: Thu, 06 Jan 2022 12:10:30 -0500 In-Reply-To: (GNU bug Tracking System's message of "Thu, 06 Jan 2022 16:14:02 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.643 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) unarchive 46374 From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 06 14:15:02 2022 Received: (at 46374) by debbugs.gnu.org; 6 Jan 2022 19:15:03 +0000 Received: from localhost ([127.0.0.1]:42344 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5YE2-0007mK-Ay for submit@debbugs.gnu.org; Thu, 06 Jan 2022 14:15:02 -0500 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:38373) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5YE0-0007lF-Dq for 46374@debbugs.gnu.org; Thu, 06 Jan 2022 14:15:00 -0500 Received: (Authenticated sender: juri@linkov.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id CE7E660006; Thu, 6 Jan 2022 19:14:51 +0000 (UTC) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#46374: Regression: erronous calls to PRED switch major-mode of unrelated modified buffers Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87r1ecilqn.fsf@haukerehfeld.de> <87a6l0cjyj.fsf@mail.linkov.net> Date: Thu, 06 Jan 2022 21:09:47 +0200 In-Reply-To: (Stefan Monnier's message of "Thu, 06 Jan 2022 11:13:46 -0500") Message-ID: <86zgo865qc.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, Hauke Rehfeld , Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > It's actually easy to distinguish this specific case: when the pred is > passed directly to `save-some-buffers` we don't need to do the "call > PRED to get the actual predicate" dance, since the caller could just as > well do that dance before calling us if that's what they want. > > IOW, the test for `save-some-buffers-function` is only needed for those > functions that come from `save-some-buffers-default-predicate`. > > Any objection to the patch below (which also aligns the code closer > with the doc since the doc of `save-some-buffers` doesn't mention the > use of the `save-some-buffers-function` property on its `pred` > argument). Then this change needs to be in the release branch, so users won't start relying on the unintended case of using of the `save-some-buffers-function` property on the `pred` argument. From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 06 15:17:01 2022 Received: (at 46374) by debbugs.gnu.org; 6 Jan 2022 20:17:01 +0000 Received: from localhost ([127.0.0.1]:42425 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5ZC0-0002R8-V8 for submit@debbugs.gnu.org; Thu, 06 Jan 2022 15:17:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55864) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5ZBz-0002Qp-53 for 46374@debbugs.gnu.org; Thu, 06 Jan 2022 15:16:59 -0500 Received: from [2001:470:142:3::e] (port=54726 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5ZBt-0007iP-3p; Thu, 06 Jan 2022 15:16:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=aDcAYaCqg/LHHwD+FYWYTfRqaLAB/EHWDKHT3yBjlAI=; b=b+92e0NjdyUv fjjf6UWAapYXdylPSXfO/gpBhI61YS7QlR+okYV9zbWlpBl0xX0pGCTvZlD/pPbt0HLJEv2VZ4u+z P+rnqqK+DnxkwJmmIHLA2/ZbvA2PwSYl65RXa+LHW3j1dpXr2dLVQAO2phTkjbtKyWVHth9UfTc2D TBkqT13WcudWhlebytGsDbj0WmY0w6g0T42LYEnWoRtPb/LsPNWPtZ8spiuw/nOKUivYT1+lH0DUZ o560ncIRJ+HPLXwpA4RBjrBymKuJ8noBeiump0nqw7n18G5WdD/iwWCd2fP5hXyHOHMPpViLtuYYW hsAPgUeszPmUi5P+YetKOA==; Received: from [87.69.77.57] (port=4473 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5ZBt-0003FU-4D; Thu, 06 Jan 2022 15:16:53 -0500 Date: Thu, 06 Jan 2022 22:17:06 +0200 Message-Id: <83h7ag7h6l.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <86zgo865qc.fsf@mail.linkov.net> (message from Juri Linkov on Thu, 06 Jan 2022 21:09:47 +0200) Subject: Re: bug#46374: Regression: erronous calls to PRED switch major-mode of unrelated modified buffers References: <878s7z4ihk.fsf@gmail.com> <87r1ecilqn.fsf@haukerehfeld.de> <87a6l0cjyj.fsf@mail.linkov.net> <86zgo865qc.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, hauke@haukerehfeld.de, monnier@iro.umontreal.ca, tino.calancha@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Date: Thu, 06 Jan 2022 21:09:47 +0200 > Cc: 46374@debbugs.gnu.org, Hauke Rehfeld , > Tino Calancha > > > It's actually easy to distinguish this specific case: when the pred is > > passed directly to `save-some-buffers` we don't need to do the "call > > PRED to get the actual predicate" dance, since the caller could just as > > well do that dance before calling us if that's what they want. > > > > IOW, the test for `save-some-buffers-function` is only needed for those > > functions that come from `save-some-buffers-default-predicate`. > > > > Any objection to the patch below (which also aligns the code closer > > with the doc since the doc of `save-some-buffers` doesn't mention the > > use of the `save-some-buffers-function` property on its `pred` > > argument). > > Then this change needs to be in the release branch, so users won't start > relying on the unintended case of using of the `save-some-buffers-function` > property on the `pred` argument. I don't see the message to which you are responding, so I cannot tell whether the patch you have in mind is appropriate for the release branch. From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 06 15:29:22 2022 Received: (at 46374) by debbugs.gnu.org; 6 Jan 2022 20:29:22 +0000 Received: from localhost ([127.0.0.1]:42439 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5ZNy-0002oJ-H3 for submit@debbugs.gnu.org; Thu, 06 Jan 2022 15:29:22 -0500 Received: from relay10.mail.gandi.net ([217.70.178.230]:48159) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5ZNu-0002o1-La for 46374@debbugs.gnu.org; Thu, 06 Jan 2022 15:29:21 -0500 Received: (Authenticated sender: juri@linkov.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 0B580240007; Thu, 6 Jan 2022 20:29:08 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#46374: Regression: erronous calls to PRED switch major-mode of unrelated modified buffers Organization: LINKOV.NET References: <878s7z4ihk.fsf@gmail.com> <87r1ecilqn.fsf@haukerehfeld.de> <87a6l0cjyj.fsf@mail.linkov.net> <86zgo865qc.fsf@mail.linkov.net> <83h7ag7h6l.fsf@gnu.org> Date: Thu, 06 Jan 2022 22:28:02 +0200 In-Reply-To: <83h7ag7h6l.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 06 Jan 2022 22:17:06 +0200") Message-ID: <86wnjczk19.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, hauke@haukerehfeld.de, monnier@iro.umontreal.ca, tino.calancha@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> Then this change needs to be in the release branch, so users won't start >> relying on the unintended case of using of the `save-some-buffers-function` >> property on the `pred` argument. > > I don't see the message to which you are responding, so I cannot tell > whether the patch you have in mind is appropriate for the release > branch. Oh, it was archived, so here is a copy: > It's actually easy to distinguish this specific case: when the pred is > passed directly to `save-some-buffers` we don't need to do the "call > PRED to get the actual predicate" dance, since the caller could just as > well do that dance before calling us if that's what they want. > > IOW, the test for `save-some-buffers-function` is only needed for those > functions that come from `save-some-buffers-default-predicate`. > > Any objection to the patch below (which also aligns the code closer > with the doc since the doc of `save-some-buffers` doesn't mention the > use of the `save-some-buffers-function` property on its `pred` > argument). > > > Stefan > > > diff --git a/lisp/files.el b/lisp/files.el > index a11786fca2c..cd43b94622e 100644 > --- a/lisp/files.el > +++ b/lisp/files.el > @@ -5799,7 +5799,7 @@ save-some-buffers-default-predicate > ;; 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") > @@ -5835,21 +5835,22 @@ save-some-buffers > 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) From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 07 09:45:47 2022 Received: (at 46374) by debbugs.gnu.org; 7 Jan 2022 14:45:47 +0000 Received: from localhost ([127.0.0.1]:43614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5qV1-0007Be-CM for submit@debbugs.gnu.org; Fri, 07 Jan 2022 09:45:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37056) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5qUy-0007BP-Gy for 46374@debbugs.gnu.org; Fri, 07 Jan 2022 09:45:46 -0500 Received: from [2001:470:142:3::e] (port=44404 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5qUr-00026B-U0; Fri, 07 Jan 2022 09:45:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=jU0EWptqpztoJzwRpYgt+g4PZMEj0qw1a12rxZkqPm4=; b=BHXmNssPrlwZ LNOFQu00EJWr1qCYeOra9I1oodJ3C/wmtHBQZl/yzHk3zJ5KECXOFw+/4FnfLYW9onO71o3jPbhPO Xe3E+g/hQ2LaDHuOBKVXu1lfAx5Npo7dHlEaBt29zfPSbr0nwrVJJwqXENa86Kq+Hjy3UVu2xCWK9 qJoC8QBWyXMeoXHu0mhwFLbpFoAc/ptLQmz2S487cHwvWnwKAJqAphknuopQ2wBm3k3fhEznl7v2t uaz2tc+XNMpayW3Oak1CvTxveLbo7t+pI/m3hXjJXzwPWnt/aAj1tP/F455oguv2ykranyzX4Jb1/ U+knyTo4+rjqy1vDXEF6mQ==; Received: from [87.69.77.57] (port=4706 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5qUr-0002ZD-Iz; Fri, 07 Jan 2022 09:45:38 -0500 Date: Fri, 07 Jan 2022 16:45:47 +0200 Message-Id: <8335lz61us.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <86wnjczk19.fsf@mail.linkov.net> (message from Juri Linkov on Thu, 06 Jan 2022 22:28:02 +0200) Subject: Re: bug#46374: Regression: erronous calls to PRED switch major-mode of unrelated modified buffers References: <878s7z4ihk.fsf@gmail.com> <87r1ecilqn.fsf@haukerehfeld.de> <87a6l0cjyj.fsf@mail.linkov.net> <86zgo865qc.fsf@mail.linkov.net> <83h7ag7h6l.fsf@gnu.org> <86wnjczk19.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, hauke@haukerehfeld.de, monnier@iro.umontreal.ca, tino.calancha@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Cc: monnier@iro.umontreal.ca, 46374@debbugs.gnu.org, > hauke@haukerehfeld.de, tino.calancha@gmail.com > Date: Thu, 06 Jan 2022 22:28:02 +0200 > > >> Then this change needs to be in the release branch, so users won't start > >> relying on the unintended case of using of the `save-some-buffers-function` > >> property on the `pred` argument. > > > > I don't see the message to which you are responding, so I cannot tell > > whether the patch you have in mind is appropriate for the release > > branch. > > Oh, it was archived, so here is a copy: Thanks. This is okay for the release branch. From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 09 22:18:51 2022 Received: (at 46374) by debbugs.gnu.org; 10 Jan 2022 03:18:51 +0000 Received: from localhost ([127.0.0.1]:51604 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n6lCr-0006xp-DQ for submit@debbugs.gnu.org; Sun, 09 Jan 2022 22:18:51 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:38764) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n6lCm-0006xY-7x for 46374@debbugs.gnu.org; Sun, 09 Jan 2022 22:18:48 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 514D544225A; Sun, 9 Jan 2022 22:18:38 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 2BD1F4419F3; Sun, 9 Jan 2022 22:18:37 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1641784717; bh=URnIZBc5csUAITdxG2WORVR8cFX1hMNplgNPS4qXTgI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=hrsrwqsVsa4HxMPmoYWZLFXlwq+U4aKkd5KfcV6vX5tQiIYE76cf62dQH4560kbbO Wrvl2AqcyGbR20vku0V2BGzpOvKu+g15LUMY8fv1yQCnlq45x3RJ/2IpWhJQNGc1eP 2bf6nWBz5U3Pe11Towt61mwV8wOcv+RcjAQkHUliYY7ae2rRHm4nUBqPBoPiQ4FClc AvTO60iGjtrX5TTcR1jfyVpP+tA9VKd+5SyGWDay+Xgkjlkg3C/pMik5Gl+RSvRFto oCYI3kbRlNVqbDOx9QA85tpsfI/2q3Oj+/rRgRkzPhIInLEVk48ZMJctffE4Azqh+d 7XjI+731NgIIw== Received: from ceviche (unknown [216.154.30.173]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E146F1204DC; Sun, 9 Jan 2022 22:18:36 -0500 (EST) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#46374: Regression: erronous calls to PRED switch major-mode of unrelated modified buffers Message-ID: References: <878s7z4ihk.fsf@gmail.com> <87r1ecilqn.fsf@haukerehfeld.de> <87a6l0cjyj.fsf@mail.linkov.net> <86zgo865qc.fsf@mail.linkov.net> <83h7ag7h6l.fsf@gnu.org> <86wnjczk19.fsf@mail.linkov.net> <8335lz61us.fsf@gnu.org> Date: Sun, 09 Jan 2022 22:18:36 -0500 In-Reply-To: <8335lz61us.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 07 Jan 2022 16:45:47 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.631 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 46374 Cc: 46374@debbugs.gnu.org, hauke@haukerehfeld.de, tino.calancha@gmail.com, Juri Linkov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Thanks. This is okay for the release branch. Thanks, installed, Stefan From unknown Sat Aug 16 21:18:13 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 07 Feb 2022 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator