[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#28248: 26.0.50; display-line-numbers does not affect window-width /

From: Eli Zaretskii
Subject: bug#28248: 26.0.50; display-line-numbers does not affect window-width / window-text-width
Date: Tue, 17 Oct 2017 19:33:28 +0300

> Cc: address@hidden, address@hidden
> From: Dmitry Gutov <address@hidden>
> Date: Tue, 17 Oct 2017 11:23:56 +0300
> On 10/17/17 5:34 AM, Eli Zaretskii wrote:
> >> Should I always use (+ 2 (line-number-display-width)) instead?
> > 
> > If you need it in columns, yes.  This is for consistency with the
> > value of display-line-numbers-width, which you can set.
> >
> >> That would be the actual amount of "screen estate used up for
> >> line-number display".
> >>
> >> Can I rely on the extra value always being 2?
> > 
> > As long as we don't change the implementation, yes.  Alternatively,
> > you can call line-number-display-width with the optional argument and
> > get the result in pixels, in which case it includes everything (you
> > can divide by frame-char-width to get the result back in columns).
> Thanks, but isn't that more inconsistent? I would expect both return 
> values of this function to measure the same thing, and there's nothing 
> in the docstring to explain that difference.

They are used for 2 different purposes, which are contradictory to
some degree.  The value in column units is primarily meant to be used
for setting display-line-numbers-width (see, e.g., how
display-line-numbers.el uses that), and also for users, so burdening
them with anything that is not directly related to the value of the
largest visible line number would be a nuisance.  OTOH, the
column-unit value is of limited utility for layout calculations,
because the columns are of the line-number face, which could be
smaller or larger than the default face.  Therefore, layout
calculations should use the function's pixelwise variety, and convert
into columns by dividing by the width of the font used for buffer
text.  (Which btw means my response to you earlier -- see above -- was
incomplete: you should use the function in pixel-unit mode, if you
need to account for the screen space eaten by line numbers, and then
you don't have to add anything to the value it returns.)

And I just noticed that we do use the column-unit values in some of
the places in Emacs that need this, so I will be fixing them soon.

> On the other hand, the return value of the function can differ from what 
> a variable is set to.

I think that'd be a nuisance; again, see what display-line-numbers.el

I agree that this is not ideal, to say the least, but I hope you at
least understand the issues now.  If there's a better solution, I'm
all ears.

> the function's docstring needs updating.



P.S. I'd still like to hear your opinions on the related questions I
asked here:


reply via email to

[Prev in Thread] Current Thread [Next in Thread]