unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour
@ 2020-07-07 21:55 Fernando Peña
  2020-07-08 14:10 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Fernando Peña @ 2020-07-07 21:55 UTC (permalink / raw)
  To: 42254

[-- Attachment #1: Type: text/plain, Size: 4097 bytes --]

Hello,

I've noticed that when displaying line numbers with
display-line-numbers-mode, the buffer shifts to the right to make space
for one more digit before the line whose number has one more digit
appears on the screen.

The line number where it shifts seems to depend on the width of the
frame, but for example with 3 digits, the buffer shifts around line 90,
before the 100th is on the screen. This happens even if the file has
less than 100 lines, leaving and excessive space on the left side of the
line numbers.

I'd expect that the buffer only shifted to the left when it was strictly
necessary. In this case, when the number 100 was shown on screen.

I hope it can be solved. I find it really annoying, especially when the
file doesn't have line numbers with that extra digit.

Greetings,

Fernando


In GNU Emacs 27.0.91 (build 1, x86_64-apple-darwin19.5.0, NS appkit-1894.50
Version 10.15.5 (Build 19F101))
of 2020-06-17 built on iMac-de-User.local
Repository revision: a71d1787f128c642f8a1fb297ef5043e20218646
Repository branch: emacs-27
Windowing system distributor 'Apple', version 10.3.1894
System Description:  Mac OS X 10.15.5

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Quit
Display-Line-Numbers mode enabled in current buffer
Making completion list...
101 (#o145, #x65, ?e)
Making completion list...

Configured using:
'configure --enable-locallisppath=/usr/local/share/emacs/site-lisp
--infodir=/usr/local/Cellar/emacs-head@27/HEAD-a71d178_1/share/info/emacs
--prefix=/usr/local/Cellar/emacs-head@27/HEAD-a71d178_1 --without-x
--without-dbus --without-imagemagick --with-modules --with-gnutls
--with-rsvg --with-xml2 --with-ns --disable-ns-self-contained
--with-harfbuzz'

Configured features:
RSVG GLIB NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS
MODULES THREADS JSON PDUMPER LCMS2 GMP

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LANG: es_ES.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  display-line-numbers-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
display-line-numbers tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads kqueue cocoa ns lcms2 multi-tty make-network-process
emacs)

Memory information:
((conses 16 45832 11204)
(symbols 48 5949 1)
(strings 32 15408 1983)
(string-bytes 1 518053)
(vectors 16 10250)
(vector-slots 8 127529 16008)
(floats 8 20 28)
(intervals 56 240 0)
(buffers 1000 13))

[-- Attachment #2: Type: text/html, Size: 18826 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour
  2020-07-07 21:55 bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour Fernando Peña
@ 2020-07-08 14:10 ` Eli Zaretskii
       [not found]   ` <CAAnJb_HZAVd2GOD7kScP_BkSRvZjkJosA2VjWz4J8jpnMdwjiQ@mail.gmail.com>
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2020-07-08 14:10 UTC (permalink / raw)
  To: Fernando Peña; +Cc: 42254

tags 42254 notabug
thanks

> From: Fernando Peña <ferpb1999@gmail.com>
> Date: Tue, 7 Jul 2020 23:55:12 +0200
> 
> I've noticed that when displaying line numbers with
> display-line-numbers-mode, the buffer shifts to the right to make space
> for one more digit before the line whose number has one more digit
> appears on the screen.
> 
> The line number where it shifts seems to depend on the width of the
> frame, but for example with 3 digits, the buffer shifts around line 90,
> before the 100th is on the screen. This happens even if the file has
> less than 100 lines, leaving and excessive space on the left side of the
> line numbers.
> 
> I'd expect that the buffer only shifted to the left when it was strictly
> necessary. In this case, when the number 100 was shown on screen.
> 
> I hope it can be solved. I find it really annoying, especially when the
> file doesn't have line numbers with that extra digit.

This is not a bug, but the intended behavior.  The design of the
line-numbers display is optimized for speed, so line numbers are
produced on the fly, without knowing exactly how many lines will fit
in the window (knowing the latter would need to produce all the lines
in a window on each redisplay, which is significantly slower).
Because the display engine doesn't know how many lines will fit, it
guesses based on the smallest font used by the frame, so it usually
overestimates, and switches to the wider field slightly before that is
actually needed.

I think it is a very small price to pay for a feature that imposes
almost no slowdown on the display operations.

If this side effect annoys you too much, I suggest to customize the
variable display-line-numbers-width-start to a non-nil value, then the
width of the line-number fields will always be exactly how much is
needed for the buffer.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour
       [not found]   ` <CAAnJb_HZAVd2GOD7kScP_BkSRvZjkJosA2VjWz4J8jpnMdwjiQ@mail.gmail.com>
@ 2020-07-08 14:50     ` Eli Zaretskii
  2020-07-08 15:02       ` Fernando Peña
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2020-07-08 14:50 UTC (permalink / raw)
  To: Fernando Peña; +Cc: 42254

[Please use Reply All to reply, so that the bug tracker gets CC'ed.]

> From: Fernando Peña <ferpb1999@gmail.com>
> Date: Wed, 8 Jul 2020 16:38:57 +0200
> 
> Okay, thanks very much for your time. Yeah, I tweaked all the variables I saw in the mode, including the one
> you mentioned. The problem is that when the buffer has 80-99 lines for example, it still shifts to the right
> when displaying the bottom.

If the variable I mentioned is non-nil, there shouldn't be any shift
at all.  Can you show an example of such a file?  Maybe there's some
bug after all.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour
  2020-07-08 14:50     ` Eli Zaretskii
@ 2020-07-08 15:02       ` Fernando Peña
  2020-07-08 15:09         ` Fernando Peña
  2020-07-08 16:21         ` Eli Zaretskii
  0 siblings, 2 replies; 8+ messages in thread
From: Fernando Peña @ 2020-07-08 15:02 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 42254

[-- Attachment #1: Type: text/plain, Size: 1250 bytes --]

Sorry for the Reply All, it's my first time mailing over here.

I tested it on different computers and it always happens.

These are the step to reproduce it:

   1. Open emacs with emacs -q
   2. Open an empty buffer
   3. M-x display-line-numbers-mode
   4. Insert 95 lines (C-u 95 RET)

You should see that there's an extra space on the left of the line numbers,
and
when you scroll up until line 90 or 85 (I think it depends on the window
size)
it disappears. If you scroll down again to the bottom, the buffer is again
shifted to the right.

El mié., 8 jul. 2020 a las 16:50, Eli Zaretskii (<eliz@gnu.org>) escribió:

> [Please use Reply All to reply, so that the bug tracker gets CC'ed.]
>
> > From: Fernando Peña <ferpb1999@gmail.com>
> > Date: Wed, 8 Jul 2020 16:38:57 +0200
> >
> > Okay, thanks very much for your time. Yeah, I tweaked all the variables
> I saw in the mode, including the one
> > you mentioned. The problem is that when the buffer has 80-99 lines for
> example, it still shifts to the right
> > when displaying the bottom.
>
> If the variable I mentioned is non-nil, there shouldn't be any shift
> at all.  Can you show an example of such a file?  Maybe there's some
> bug after all.
>

[-- Attachment #2: Type: text/html, Size: 2074 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour
  2020-07-08 15:02       ` Fernando Peña
@ 2020-07-08 15:09         ` Fernando Peña
  2020-07-08 16:21         ` Eli Zaretskii
  1 sibling, 0 replies; 8+ messages in thread
From: Fernando Peña @ 2020-07-08 15:09 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 42254

[-- Attachment #1: Type: text/plain, Size: 1536 bytes --]

The behaviour is the same whether  display-line-numbers-width-start is set
or
not to non-nil, and if you save the file and reopen it again.

El mié., 8 jul. 2020 a las 17:02, Fernando Peña (<ferpb1999@gmail.com>)
escribió:

> Sorry for the Reply All, it's my first time mailing over here.
>
> I tested it on different computers and it always happens.
>
> These are the step to reproduce it:
>
>    1. Open emacs with emacs -q
>    2. Open an empty buffer
>    3. M-x display-line-numbers-mode
>    4. Insert 95 lines (C-u 95 RET)
>
> You should see that there's an extra space on the left of the line
> numbers, and
> when you scroll up until line 90 or 85 (I think it depends on the window
> size)
> it disappears. If you scroll down again to the bottom, the buffer is again
> shifted to the right.
>
> El mié., 8 jul. 2020 a las 16:50, Eli Zaretskii (<eliz@gnu.org>) escribió:
>
>> [Please use Reply All to reply, so that the bug tracker gets CC'ed.]
>>
>> > From: Fernando Peña <ferpb1999@gmail.com>
>> > Date: Wed, 8 Jul 2020 16:38:57 +0200
>> >
>> > Okay, thanks very much for your time. Yeah, I tweaked all the variables
>> I saw in the mode, including the one
>> > you mentioned. The problem is that when the buffer has 80-99 lines for
>> example, it still shifts to the right
>> > when displaying the bottom.
>>
>> If the variable I mentioned is non-nil, there shouldn't be any shift
>> at all.  Can you show an example of such a file?  Maybe there's some
>> bug after all.
>>
>

[-- Attachment #2: Type: text/html, Size: 2819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour
  2020-07-08 15:02       ` Fernando Peña
  2020-07-08 15:09         ` Fernando Peña
@ 2020-07-08 16:21         ` Eli Zaretskii
  2020-07-08 17:02           ` Fernando Peña
  2020-08-13  0:29           ` Stefan Kangas
  1 sibling, 2 replies; 8+ messages in thread
From: Eli Zaretskii @ 2020-07-08 16:21 UTC (permalink / raw)
  To: Fernando Peña; +Cc: 42254

> From: Fernando Peña <ferpb1999@gmail.com>
> Date: Wed, 8 Jul 2020 17:02:40 +0200
> Cc: 42254@debbugs.gnu.org
> 
> 1 Open emacs with emacs -q
> 2 Open an empty buffer
> 3 M-x display-line-numbers-mode
> 4 Insert 95 lines (C-u 95 RET)
> 
> You should see that there's an extra space on the left of the line numbers, and
> when you scroll up until line 90 or 85 (I think it depends on the window size)
> it disappears. If you scroll down again to the bottom, the buffer is again
> shifted to the right.

Ah, okay.  If you add lines, then yes, it will eventually shift.
Sorry I didn't get that before.

So: no bug.

Thanks.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour
  2020-07-08 16:21         ` Eli Zaretskii
@ 2020-07-08 17:02           ` Fernando Peña
  2020-08-13  0:29           ` Stefan Kangas
  1 sibling, 0 replies; 8+ messages in thread
From: Fernando Peña @ 2020-07-08 17:02 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 42254

[-- Attachment #1: Type: text/plain, Size: 824 bytes --]

Okay, thanks for replying.

Greetings,
Fernando

El mié., 8 jul. 2020 a las 18:21, Eli Zaretskii (<eliz@gnu.org>) escribió:

> > From: Fernando Peña <ferpb1999@gmail.com>
> > Date: Wed, 8 Jul 2020 17:02:40 +0200
> > Cc: 42254@debbugs.gnu.org
> >
> > 1 Open emacs with emacs -q
> > 2 Open an empty buffer
> > 3 M-x display-line-numbers-mode
> > 4 Insert 95 lines (C-u 95 RET)
> >
> > You should see that there's an extra space on the left of the line
> numbers, and
> > when you scroll up until line 90 or 85 (I think it depends on the window
> size)
> > it disappears. If you scroll down again to the bottom, the buffer is
> again
> > shifted to the right.
>
> Ah, okay.  If you add lines, then yes, it will eventually shift.
> Sorry I didn't get that before.
>
> So: no bug.
>
> Thanks.
>

[-- Attachment #2: Type: text/html, Size: 1605 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour
  2020-07-08 16:21         ` Eli Zaretskii
  2020-07-08 17:02           ` Fernando Peña
@ 2020-08-13  0:29           ` Stefan Kangas
  1 sibling, 0 replies; 8+ messages in thread
From: Stefan Kangas @ 2020-08-13  0:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Fernando Peña, 42254-done

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Fernando Peña <ferpb1999@gmail.com>
>> Date: Wed, 8 Jul 2020 17:02:40 +0200
>> Cc: 42254@debbugs.gnu.org
>>
>> 1 Open emacs with emacs -q
>> 2 Open an empty buffer
>> 3 M-x display-line-numbers-mode
>> 4 Insert 95 lines (C-u 95 RET)
>>
>> You should see that there's an extra space on the left of the line numbers, and
>> when you scroll up until line 90 or 85 (I think it depends on the window size)
>> it disappears. If you scroll down again to the bottom, the buffer is again
>> shifted to the right.
>
> Ah, okay.  If you add lines, then yes, it will eventually shift.
> Sorry I didn't get that before.
>
> So: no bug.

I'm therefore closing this bug report.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-08-13  0:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 21:55 bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour Fernando Peña
2020-07-08 14:10 ` Eli Zaretskii
     [not found]   ` <CAAnJb_HZAVd2GOD7kScP_BkSRvZjkJosA2VjWz4J8jpnMdwjiQ@mail.gmail.com>
2020-07-08 14:50     ` Eli Zaretskii
2020-07-08 15:02       ` Fernando Peña
2020-07-08 15:09         ` Fernando Peña
2020-07-08 16:21         ` Eli Zaretskii
2020-07-08 17:02           ` Fernando Peña
2020-08-13  0:29           ` Stefan Kangas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).