GNU bug report logs - #46374
28.0.50; Ask me to save buffers only if they are under callers dir

Previous Next

Package: emacs;

Reported by: Tino Calancha <tino.calancha <at> gmail.com>

Date: Sun, 7 Feb 2021 22:33:01 UTC

Severity: wishlist

Tags: fixed

Merged with 50380

Fixed in version 28.0.60

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


Message #142 received at 46374 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 46374 <at> debbugs.gnu.org, hauke <at> haukerehfeld.de, monnier <at> iro.umontreal.ca,
 tino.calancha <at> gmail.com
Subject: Re: bug#46374: Regression: erronous calls to PRED switch major-mode
 of unrelated modified buffers
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:

> 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)




This bug report was last modified 3 years and 192 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.