Subject: bug#29597: 26.0.90; line-number-display-width returns incorrect width

From: Paul Rankin <[email-masked]>
Date: Fri, 08 Dec 2017 12:32:31 +1000

On Fri, 8 Dec 2017, at 12:00 PM, Noam Postavsky wrote:

> Here's the help text:
> 
>     line-number-display-width is a built-in function in ‘C source code’.
> 
>     (line-number-display-width &optional PIXELWISE)
> 
>     Return the width used for displaying line numbers in the selected window.
>     If optional argument PIXELWISE is the symbol ‘columns’, return the width
>     in units of the frame’s canonical character width.  In this case, the
>     value is a float.
>     If optional argument PIXELWISE is t or any other non-nil value, return
>     the width as an integer number of pixels.
>     Otherwise return the value as an integer number of columns of the face
>     used to display line numbers, ‘line-number’.  Note that in the latter
>     case, the value doesn’t include the 2 columns used for padding the
>     numbers on display.

Thanks Noam, much appreciation 🙏

I’m sorry to be so blunt, but did anyone actually read this? I’ve read over it several times and cannot understand the writer thought it would make sense to anyone not already intimately familiar with the code. The questions that arise....

- Why does an argument PIXELWISE take a symbol “columns”? 
- Why does PIXELWISE then return characters?
- Still, why would the function not just return the width of the line numbers *with* the 2 columns for padding?

I mean, we’re not dealing with some deeply entrenched internal function where these sorts of mental contortions are required to maintain backwards compatibility, this is a *new* feature.

I understand that this function is also used internally for specific purposes, so it needs to behave a specific way to appease the initial writer of the code. But for the sake of sanity, I strongly suggest either fixing this function or creating a separate “public” function that operates vaguely in line with user expectation for those of us wanting to accommodate display-line-numbers-mode.