Subject: bug#76734: 31.0.50; The line numbers take more space than they need

From: the_wurfkreuz <[email-masked]>
Date: Tue, 04 Mar 2025 19:59:57 +0000

Sent with Proton Mail secure email.

On Tuesday, March 4th, 2025 at 2:55 PM, Eli Zaretskii <[email-masked]> wrote:

> tags 76734 notabug
> thanks
> 
> > Date: Tue, 04 Mar 2025 06:31:00 +0000
> > From: the_wurfkreuz via "Bug reports for GNU Emacs,
> > the Swiss army knife of text editors" [email-masked]
> > 
> > When using the line-numbers mode, the line numbers start to take an
> > additional space from a buffer way before the line count reaches 3
> > digit numbers.
> > 
> > Steps to reproduce:
> > 
> > 1. Evaluate:
> > 
> > (global-display-line-numbers-mode 1)
> > (setq display-line-numbers 'visual
> > display-line-numbers-type 'relative)
> > 
> > (fringe-mode '(1 . 1))
> > 
> > 2. Then create new lines in the same buffer using the newline
> > command. In my case i get an additional space on a 38th line already.
> 
> 
> This is by design. Emacs cannot know how many lines will actually be
> shown in the window before it actually shows them all. By contrast,
> it needs to decide how many columns to allocate for line numbers
> before it displays even a single line, to avoid the annoying
> horizontal movement of text as much as possible. So it sometimes errs
> on the safe side (recall that some lines could be smaller than others
> due to different fonts), to avoid the need to display the window
> twice, which would significantly punish performance in this mode.
> 
> Why is that a problem?

If it's done so intentionally, then there is no inherent problem.