Subject: bug#67248: 30.0.50; string-pixel-width is affected by the global value of display-line-numbers

From: Eli Zaretskii <[email-masked]>
Date: Sat, 18 Nov 2023 09:14:24 +0200

> Date: Fri, 17 Nov 2023 23:23:58 +0200
> From: Dmitry Gutov <[email-masked]>
> 
> 1. (string-pixel-width "abc") ; => 51
> 2. (customize-set-variable 'display-line-numbers t)
> 3. (string-pixel-width "abc") ; => 119
> 
> This function's implementation makes provision for
> display-line-numbers-mode, but not for the original variable
> display-line-numbers, which will be t independent of the value of
> display-line-numbers-mode.
> 
> I think it's a bad idea to have these two different ways to do the same
> thing, and it can lead to bugs like this one. I would suggest obsoleting
> the public use of display-line-numbers -- making it private, probably.
> At least removing it from the customization group display-line-numbers.

I don't see a need for such drastic measures, certainly not due to
this bug.  Having the variable and the mode in this case is not
different from other similar cases, for example, word-wrap vs
visual-line-mode.  You have just discovered that the test in
string-pixel-width was not the correct one, that's all.

> Barring that, the patch below seems to work.  Although it proliferates
> the differences between Emacs versions which one would have to be on the
> lookout for.

Thanks, I think this is indeed the right solution.  Please install the
patch on the emacs-29 branch.