unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: jonas@bernoul.li, 65414@debbugs.gnu.org
Subject: bug#65414: save-some-buffers-functions are unexpectedly called when save-some-buffers pred is non-nil
Date: Sat, 26 Aug 2023 00:32:23 -0700	[thread overview]
Message-ID: <874jkmck9j.fsf@breatheoutbreathe.in> (raw)
In-Reply-To: <838r9ymfh5.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 940 bytes --]


Eli Zaretskii <eliz@gnu.org> writes:
> So your problem is with Lisp programs that add functions to
> save-some-buffers-functions, but don't expect or don't want those
> functions to be called each time save-some-buffers is invoked?

Yes.

> I'm not sure how did those Lisp programs get the idea that
> save-some-buffers-functions will not be called always -- is it hinted
> by some documentation somewhere?  If not, I'd say that those Lisp
> programs have a bug that needs to be fixed in those programs.  Right?

I agree.

> In any case, not calling save-some-buffers-functions when PRED is
> non-nil is not something we can do, as that would be an incompatible
> behavior change.  We could perhaps add PRED to the arguments with
> which save-some-buffers-functions are called, as an optional argument.
> Would that be satisfactory?

Yes, that would solve the interference between Magit and hyperdrive.el.

See patch.

Thank you!

Joseph


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Pass-PRED-to-each-of-save-some-buffers-functions.patch --]
[-- Type: text/x-diff, Size: 2175 bytes --]

From 28e8745b579da5f83afc7f9eb5b5ed2df2f3204e Mon Sep 17 00:00:00 2001
From: Joseph Turner <joseph@breatheoutbreathe.in>
Date: Sat, 26 Aug 2023 00:50:28 -0700
Subject: [PATCH] Pass PRED to each of save-some-buffers-functions

* lisp/abbrev.el (abbrev--possibly-save): Ignore PRED
* lisp/files.el (save-some-buffers-functions): Fix documentation
(save-some-buffers): Pass PRED to each of save-some-buffers-functions
---
 lisp/abbrev.el | 2 +-
 lisp/files.el  | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index e1311dbc83b..43e7c7e5e5d 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -1242,7 +1242,7 @@ which see."
               '(edit-abbrevs-mode-font-lock-keywords nil nil ((?_ . "w"))))
   (setq font-lock-multiline nil))
 
-(defun abbrev--possibly-save (query &optional arg)
+(defun abbrev--possibly-save (query &optional arg _pred)
   ;; Query mode.
   (if (eq query 'query)
       (and save-abbrevs abbrevs-changed)
diff --git a/lisp/files.el b/lisp/files.el
index 29d109ab385..6ab10cc3310 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6003,8 +6003,8 @@ function should return non-nil if there is something to be
 saved (but it should not actually save anything).
 
 If the first argument is something else, then the function should
-save according to the value of the second argument, which is the
-ARG argument from `save-some-buffers'.")
+save according to the values of the second and third arguments,
+which are the ARG and PRED arguments from `save-some-buffers'.")
 
 (defun save-some-buffers (&optional arg pred)
   "Save some modified file-visiting buffers.  Asks user about each one.
@@ -6099,7 +6099,7 @@ after saving the buffers."
 	         save-some-buffers-action-alist))
           ;; Allow other things to be saved at this time, like abbrevs.
           (dolist (func save-some-buffers-functions)
-            (setq inhibit-message (or (funcall func nil arg) inhibit-message)))
+            (setq inhibit-message (or (funcall func nil arg pred) inhibit-message)))
           (or queried (> files-done 0) inhibit-message
 	      (cond
 	       ((null autosaved-buffers)
-- 
2.41.0


  reply	other threads:[~2023-08-26  7:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-21  4:06 bug#65414: save-some-buffers-functions are unexpectedly called when save-some-buffers pred is non-nil Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-21 11:56 ` Eli Zaretskii
2023-08-23 23:57   ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-24  5:16     ` Eli Zaretskii
2023-08-26  6:38       ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-26  7:26         ` Eli Zaretskii
2023-08-26  7:32           ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-09-02  7:30             ` Eli Zaretskii
2023-09-03 17:06               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-03 17:29                 ` Eli Zaretskii
2023-09-03 17:52                 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-03 19:03                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-03 19:04                     ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-04 10:53                   ` Eli Zaretskii
2023-09-04 15:54                     ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-04 15:59                       ` Eli Zaretskii
2023-09-03 17:22               ` Juri Linkov
2023-09-03 17:44                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874jkmck9j.fsf@breatheoutbreathe.in \
    --to=bug-gnu-emacs@gnu.org \
    --cc=65414@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=jonas@bernoul.li \
    --cc=joseph@breatheoutbreathe.in \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).