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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 09 Nov 2024 13:13:52 +0200

> From: Eshel Yaron <[email-masked]>
> Cc: [email-masked]
> Date: Wed, 06 Nov 2024 15:12:24 +0100
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> From: Eshel Yaron <[email-masked]>
> >> Cc: [email-masked]
> >> Date: Wed, 06 Nov 2024 09:01:16 +0100
> >> 
> >> FYI after spending a bit more time on this issue, I concluded that
> >> (kill-all-local-variables t) is inherently problematic: it breaks
> >> assumptions that Emacs relies on.  (See bug#73005 for another example.)
> >> 
> >> It doesn't seem like killing permanent-local variables in the work
> >> buffers is necessary ATM, so the fix I'm using is the following:
> >
> > Can't _any_ variable become permanent-local, by virtue of some Lisp
> > program or the user giving it a permanent-local property?
> >
> > More generally, how do we know that there are no permanent-local
> > variables out there that affect layout, and thus affect the results of
> > this function?
> >
> > I believe these considerations were those which led the author to use
> > kill-all-local-variables like this: we want to be sure that nothing
> > will dupe string-pixel-width into producing unexpected results.
> 
> Yes, this reasoning is perfectly understandable.  However, the current
> way of killing all permanent-local variables has bad consequences that
> that author, naturally, did not expect.  So my suggestion is to avoid
> (kill-all-local-variables t) here and elsewhere.
> 
> For string-pixel-width specifically, we take care to clear variables
> that may affect width calculation.  If other variables may interfere, we
> should just clear those too.

Let's see what Stefan (CC'ed) thinks about these issues.