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

From: Stefan Monnier <[email-masked]>
Date: Sat, 09 Nov 2024 11:26:48 -0500

> Killing local variables makes the global value of deactivate-mark be
> in effect when the command loop decides whether to deactivate the
> region after a command finishes.

The thing I don't understand is this:

    Why is the global value of `deactivate-mark` non-nil?

After all, since it is buffer-local when set, it should only be non-nil
buffer-locally, so the `kill-all-local-variables` should just through
away the non-nil setting, whereas it seems that somehow the non-nil
setting gets "promoted" to global.

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.

        Stefan