GNU bug report logs - #38717
display-line-numbers set to relative

Previous Next

Package: emacs;

Reported by: "Franco A. Cortesi" <cortesifranco3 <at> gmail.com>

Date: Mon, 23 Dec 2019 04:03:02 UTC

Severity: minor

Tags: notabug

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 38717 in the body.
You can then email your comments to 38717 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#38717; Package emacs. (Mon, 23 Dec 2019 04:03:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Franco A. Cortesi" <cortesifranco3 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 23 Dec 2019 04:03:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Franco A. Cortesi" <cortesifranco3 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: display-line-numbers set to relative
Date: Mon, 23 Dec 2019 00:49:47 -0300
[Message part 1 (text/plain, inline)]
When display-line-numbers is set to 'relative', the number of spaces before
the digits starts growing (to two) when the current line hits 43 in my
case. Of course, no other line has more than two digits as the screen only
has 56 lines in total so the growing of spaces (and columns) is not needed
at all and of course is undesired. This behavior seems to be correctly
implemented but for absolute line numbers, where hitting line 43 means the
bottom line is close to start showing numbers with three digits.

The current line always showing the absolute line number is another big
problem as it will make the number of columns to grow and srink anyway.
This growing and shrinking could be totally prevented if users were able to
remove or configure the contents of the current line indicator. If
configurable, a custom face would be also very good. For example a colored
"-" indicating the current line would be nice for many users.

Lastly and less important, it would be great to be able to remove the space
before the first numeric character! To make line-numbers-mode as less
invasive and noticeable as possible.


This feature (relative line numbers) is AWESOME, especially when used with
evil-mode as it allows to navigate the code VERY fast by prefixing
next/previous-line commands with exact numbers. No "fast mental math" (when
using absolute line-numbers) or inaccurate guessings are needed, only
correct information. But I think the first two issues should be addresed to
make relative line-numbers really usable without drawbacks.

Thank you for reading.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38717; Package emacs. (Mon, 23 Dec 2019 06:44:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Franco A. Cortesi" <cortesifranco3 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: display-line-numbers set to relative
Date: Mon, 23 Dec 2019 01:35:55 -0300
[Message part 1 (text/plain, inline)]
Of course, evil-mode has a <gg> command, meaning "go to nth line", where
the number of line is absolute and could be used with
absolute_line_numbers. But I think nobody commonly uses this <gg> command,
or at least, this command is not needed as relative line numbers allows the
same behavior with the far more used and easier <j> and  <k> commands,
meaning "nex-line" and "previous line". Also moving around with relative
numbers will always be two digits (key presses) while absolute can be quite
higher. I don't understand why relative line numbers are so uncommon.



Le lun. 23 déc. 2019 à 00:49, Franco A. Cortesi <cortesifranco3 <at> gmail.com>
a écrit :

> When display-line-numbers is set to 'relative', the number of spaces
> before the digits starts growing (to two) when the current line hits 43 in
> my case. Of course, no other line has more than two digits as the screen
> only has 56 lines in total so the growing of spaces (and columns) is not
> needed at all and of course is undesired. This behavior seems to be
> correctly implemented but for absolute line numbers, where hitting line 43
> means the bottom line is close to start showing numbers with three digits.
>
> The current line always showing the absolute line number is another big
> problem as it will make the number of columns to grow and srink anyway.
> This growing and shrinking could be totally prevented if users were able to
> remove or configure the contents of the current line indicator. If
> configurable, a custom face would be also very good. For example a colored
> "-" indicating the current line would be nice for many users.
>
> Lastly and less important, it would be great to be able to remove the
> space before the first numeric character! To make line-numbers-mode as less
> invasive and noticeable as possible.
>
>
> This feature (relative line numbers) is AWESOME, especially when used with
> evil-mode as it allows to navigate the code VERY fast by prefixing
> next/previous-line commands with exact numbers. No "fast mental math" (when
> using absolute line-numbers) or inaccurate guessings are needed, only
> correct information. But I think the first two issues should be addresed to
> make relative line-numbers really usable without drawbacks.
>
> Thank you for reading.
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38717; Package emacs. (Mon, 23 Dec 2019 13:49:02 GMT) Full text and rfc822 format available.

Message #11 received at 38717 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "Franco A. Cortesi" <cortesifranco3 <at> gmail.com>
Cc: 38717 <at> debbugs.gnu.org
Subject: Re: bug#38717: display-line-numbers set to relative
Date: Mon, 23 Dec 2019 15:47:53 +0200
tags 38717 notabug
thanks

> From: "Franco A. Cortesi" <cortesifranco3 <at> gmail.com>
> Date: Mon, 23 Dec 2019 00:49:47 -0300
> 
> When display-line-numbers is set to 'relative', the number of spaces before the digits starts growing (to two)
> when the current line hits 43 in my case. Of course, no other line has more than two digits as the screen only
> has 56 lines in total so the growing of spaces (and columns) is not needed at all and of course is undesired.
> This behavior seems to be correctly implemented but for absolute line numbers, where hitting line 43 means
> the bottom line is close to start showing numbers with three digits.

This is a side effect of the implementation, which avoids scanning the
entire area to be displayed twice, and instead estimates the maximum
width of a line number when the first line of a window is displayed,
and then sticks to that width for that window.  Since Emacs can
display variable-size fonts in the same window-full, it must be
pessimistic and assume the smallest possible font (which makes the
last line's number become larger, and cross the 3-digits threshold
sooner).

I don't think this is too much to pay for lightning-fast display of
line numbers (unlike linum.el and similar modes).

> The current line always showing the absolute line number is another big problem as it will make the number
> of columns to grow and srink anyway. This growing and shrinking could be totally prevented if users were able
> to remove or configure the contents of the current line indicator. If configurable, a custom face would be also
> very good. For example a colored "-" indicating the current line would be nice for many users.

Sounds like you want to customize the option
display-line-numbers-current-absolute, and maybe also to customize the
line-number-current-face face.

In general, I suggest to type

   M-x customize-group RET display-line-numbers RET

and review the customizable options this mode offers, you might find
something you want to change from the default.  (The most important
options are also described in the Emacs manual.)

> Lastly and less important, it would be great to be able to remove the space before the first numeric character!

Cannot be done easily, because Emacs supports right-to-left text,
where line numbers appear on the right, and when the line number is
rendered, Emacs doesn't yet know whether the text after the line
number is R2L or L2R.




Added tag(s) notabug. Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 23 Dec 2019 13:49:02 GMT) Full text and rfc822 format available.

Reply sent to Stefan Kangas <stefan <at> marxist.se>:
You have taken responsibility. (Wed, 15 Jan 2020 19:51:02 GMT) Full text and rfc822 format available.

Notification sent to "Franco A. Cortesi" <cortesifranco3 <at> gmail.com>:
bug acknowledged by developer. (Wed, 15 Jan 2020 19:51:03 GMT) Full text and rfc822 format available.

Message #18 received at 38717-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 38717-done <at> debbugs.gnu.org, "Franco A. Cortesi" <cortesifranco3 <at> gmail.com>
Subject: Re: bug#38717: display-line-numbers set to relative
Date: Wed, 15 Jan 2020 20:50:26 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

> tags 38717 notabug
> thanks
>
>> From: "Franco A. Cortesi" <cortesifranco3 <at> gmail.com>
>> Date: Mon, 23 Dec 2019 00:49:47 -0300
>> 
>> When display-line-numbers is set to 'relative', the number of spaces before the digits starts growing (to two)
>> when the current line hits 43 in my case. Of course, no other line has more than two digits as the screen only
>> has 56 lines in total so the growing of spaces (and columns) is not needed at all and of course is undesired.
>> This behavior seems to be correctly implemented but for absolute line numbers, where hitting line 43 means
>> the bottom line is close to start showing numbers with three digits.
>
> This is a side effect of the implementation, which avoids scanning the
> entire area to be displayed twice, and instead estimates the maximum
> width of a line number when the first line of a window is displayed,
> and then sticks to that width for that window.  Since Emacs can
> display variable-size fonts in the same window-full, it must be
> pessimistic and assume the smallest possible font (which makes the
> last line's number become larger, and cross the 3-digits threshold
> sooner).
>
> I don't think this is too much to pay for lightning-fast display of
> line numbers (unlike linum.el and similar modes).
>
>> The current line always showing the absolute line number is another big problem as it will make the number
>> of columns to grow and srink anyway. This growing and shrinking could be totally prevented if users were able
>> to remove or configure the contents of the current line indicator. If configurable, a custom face would be also
>> very good. For example a colored "-" indicating the current line would be nice for many users.
>
> Sounds like you want to customize the option
> display-line-numbers-current-absolute, and maybe also to customize the
> line-number-current-face face.
>
> In general, I suggest to type
>
>    M-x customize-group RET display-line-numbers RET
>
> and review the customizable options this mode offers, you might find
> something you want to change from the default.  (The most important
> options are also described in the Emacs manual.)
>
>> Lastly and less important, it would be great to be able to remove the space before the first numeric character!
>
> Cannot be done easily, because Emacs supports right-to-left text,
> where line numbers appear on the right, and when the line number is
> rendered, Emacs doesn't yet know whether the text after the line
> number is R2L or L2R.

So it seems like there is nothing to do here and I'm closing this bug.

Best regards,
Stefan Kangas




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 13 Feb 2020 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 132 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.