bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#46374: Regression: erronous calls to PRED switch major-mode of unrel


From: Juri Linkov
Subject: bug#46374: Regression: erronous calls to PRED switch major-mode of unrelated modified buffers
Date: Thu, 06 Jan 2022 22:28:02 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu)

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





reply via email to

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