Subject: Re: bug#74091: 31.0.50; string-pixel-width in mode line disables region

From: Stefan Monnier <[email-masked]>
Date: Sat, 09 Nov 2024 13:06:13 -0500

>> I suspect the problem might be a bug in `reset_buffer_local_variables` around:
>> 
>>     /* Reset all (or most) per-buffer variables to their defaults.  */
>>     if (permanent_too)
>>       bset_local_var_alist (b, Qnil);
>> 
>> I suspect this was OK in the "original" uses of `permanent_too` because
>> "by construction" none of those vars could be "swapped in" (i.e. have
>> their value held in a C variable like `Vdeactivate_mark`), but we now
>> have cases where this is not the case any more, so that if the value of
>> `Vdeactivate_mark` held a buffer-local value, it ends up "promoted"
>> to global.

Hmm... I was wrong, it's not actually promoted to global, it's just that
the former local value "lingers".

> Which development in Emacs made such a "promotion" possible?

AFAICT the problem is new with the addition of the `kill-permanent`
arg to `kill-all-local-variables`.

Here's an example of a problem:

    src/emacs -Q --batch --eval '(message "%s" (list (setq-default foo nil) (setq-local foo t) (kill-all-local-variables t) (local-variable-p `foo) foo (default-value `foo) (with-temp-buffer foo) foo))'

=>

    (nil t nil t t nil nil nil)

If we call `kill-all-local-variables` without the additional argument, we
get the correct answer:

    (nil t nil nil nil nil nil nil)

- Stefan