Subject: Re: bug#78608: 31.0.50; Todo mode bug revealed by setq-default change

From: Stefan Monnier <[email-masked]>
Date: Sat, 31 May 2025 12:50:57 -0400

> In short: with `setq-local' in master, if you do this:
>
>    (setq-local var (setq var val))
>
> within a `with-current-buffer' form, then `val' survives after exiting
> the form, but not if you do this:
>
>    (setq-local var val)
>
> In emacs-30, `val' does not survive in either case.  I think this
> difference is what Stefan was referring by "can occasionally affect code
> in surprising ways if the computation of the value refers to the
> variable."

In the original problem that prompted the fix to `setq-local`, I think
there was no `setq` involved, but "refers to the variable" is probably
too vague (and suggests that merely asking for the var's value could
also be affected, which I believe is not the case).  So maybe:

    ... can occasionally affect code in surprising ways if the
    computation of the value itself modifies the variable.

where "modifies" could be a `defvar`, `setq`, `let`, ...

> But Stefan, when you said you failed to "figure out what was the
> specific origin of the problem" in the todo-mode case, did you mean
> something else than using `setq' within `setq-local'?

No, the "`setq' within `setq-local'" is the part that I failed to figure
out, thanks.

        Stefan