unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#71323: 28.2; global-display-line-numbers-mode in org file do strange identation when headers are folded
@ 2024-06-02  9:10 Mikhail Efremov
  2024-06-02 12:20 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Mikhail Efremov @ 2024-06-02  9:10 UTC (permalink / raw)
  To: 71323

Hi, Emacs devs,

* Description

There is an issue with not so large org files with
global-display-line-numbers-mode is toggled on. You may reproduce it:

1. ~emacs -Q~
2. open an org file with 1000+ lines of different headers' layers
unfolded.
3. ~M-x global-display-line-numbers-mode~
4. Check that unfolded headers on lines 999-1000 are indented fine:
  - numbers are right-aligned;
  - same-level headers are indented equally with the same indent width
  relative to line numbers.
5. Fold all headers with the property: on the screen of the buffer
there
are single-, two- and three-digits lines' numbers are presented.

Then, you should see the picture like this:

  1 * header1
 24 * header2
132 * header3
1019 * header4

The same behavior is on ~emacs -nw -Q~.

The issue is valid also on built from sources emacs: GNU Emacs 29.3
(build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version
1.16.0) of 2024-04-08

* Motivation

This behavior on the one hand constantly shifts
left-to-right-and-vice-versa the buffer's text and also confuses with
headers' identation level.

* Definition of Done

After the steps of reproducing the desired view is:
   1 * header1
  24 * header2
 132 * header3
1019 * header4

* Details of implementation

I guess there is a problem with line's mode algorithm, from my side it
looks like it taking into account only 1 digit difference for an
identation, then if there is 2 or more digits differnece, then all
after
the first-digit diff identations are broken.

The posible solution is to count total lines number and reserving
line's
numbers side width from total lines count number's width.

Thank you a lot!
Sincerely, Mikhail Efremov.

---

In GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37,
cairo version 1.16.0)
 of 2023-05-14, modified by Debian built on x86-ubc-01
Windowing system distributor 'The X.Org Foundation', version
11.0.12201009
System Description: Debian GNU/Linux 12 (bookworm)

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/libexec
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/28.2/site-
lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/28.2/site-
lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils
 --with-native-compilation --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/libexec
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/28.2/site-
lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/28.2/site-
lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils
 --with-native-compilation --with-cairo --with-x=yes
 --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -ffile-prefix-map=/build/emacs-mPr7Vr/emacs-28.2+1=. -fstack-
protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB

Important settings:
  value of $LC_MONETARY: en_GB.UTF-8
  value of $LC_NUMERIC: en_GB.UTF-8
  value of $LC_TIME: en_GB.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Org

Minor modes in effect:
  text-scale-mode: t
  org-indent-mode: t
  shell-dirtrack-mode: t
  recentf-mode: t
  global-display-line-numbers-mode: t
  display-line-numbers-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-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
  column-number-mode: t
  line-number-mode: t
  auto-fill-function: org-auto-fill-function
  visual-line-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/jakutenshi/.config/emacs/elpa/emacsql-sqlite-3.1.1/emacsql-sqlite
hides /home/jakutenshi/.config/emacs/elpa/emacsql-3.1.1/emacsql-sqlite
/home/jakutenshi/.config/emacs/elpa/use-package-2.4.5/bind-key hides
/home/jakutenshi/.config/emacs/elpa/bind-key-2.4.1/bind-key
~/bin/git_src/org-mode/lisp/ox-koma-letter hides
/usr/share/emacs/28.2/lisp/org/ox-koma-letter
~/bin/git_src/org-mode/lisp/org-agenda hides
/usr/share/emacs/28.2/lisp/org/org-agenda
~/bin/git_src/org-mode/lisp/ox-latex hides
/usr/share/emacs/28.2/lisp/org/ox-latex
~/bin/git_src/org-mode/lisp/ol-gnus hides
/usr/share/emacs/28.2/lisp/org/ol-gnus
~/bin/git_src/org-mode/lisp/ob hides /usr/share/emacs/28.2/lisp/org/ob
~/bin/git_src/org-mode/lisp/org-num hides
/usr/share/emacs/28.2/lisp/org/org-num
~/bin/git_src/org-mode/lisp/org-goto hides
/usr/share/emacs/28.2/lisp/org/org-goto
~/bin/git_src/org-mode/lisp/ob-latex hides
/usr/share/emacs/28.2/lisp/org/ob-latex
~/bin/git_src/org-mode/lisp/ob-css hides
/usr/share/emacs/28.2/lisp/org/ob-css
~/bin/git_src/org-mode/lisp/org-faces hides
/usr/share/emacs/28.2/lisp/org/org-faces
~/bin/git_src/org-mode/lisp/ol hides /usr/share/emacs/28.2/lisp/org/ol
~/bin/git_src/org-mode/lisp/ox-org hides
/usr/share/emacs/28.2/lisp/org/ox-org
~/bin/git_src/org-mode/lisp/oc-csl hides
/usr/share/emacs/28.2/lisp/org/oc-csl
~/bin/git_src/org-mode/lisp/org-indent hides
/usr/share/emacs/28.2/lisp/org/org-indent
~/bin/git_src/org-mode/lisp/ob-org hides
/usr/share/emacs/28.2/lisp/org/ob-org
~/bin/git_src/org-mode/lisp/org-tempo hides
/usr/share/emacs/28.2/lisp/org/org-tempo
~/bin/git_src/org-mode/lisp/org-list hides
/usr/share/emacs/28.2/lisp/org/org-list
~/bin/git_src/org-mode/lisp/org-attach hides
/usr/share/emacs/28.2/lisp/org/org-attach
~/bin/git_src/org-mode/lisp/ob-plantuml hides
/usr/share/emacs/28.2/lisp/org/ob-plantuml
~/bin/git_src/org-mode/lisp/org-duration hides
/usr/share/emacs/28.2/lisp/org/org-duration
~/bin/git_src/org-mode/lisp/org-lint hides
/usr/share/emacs/28.2/lisp/org/org-lint
~/bin/git_src/org-mode/lisp/ob-lob hides
/usr/share/emacs/28.2/lisp/org/ob-lob
~/bin/git_src/org-mode/lisp/org-pcomplete hides
/usr/share/emacs/28.2/lisp/org/org-pcomplete
~/bin/git_src/org-mode/lisp/org-ctags hides
/usr/share/emacs/28.2/lisp/org/org-ctags
~/bin/git_src/org-mode/lisp/ob-makefile hides
/usr/share/emacs/28.2/lisp/org/ob-makefile
~/bin/git_src/org-mode/lisp/ol-eww hides
/usr/share/emacs/28.2/lisp/org/ol-eww
~/bin/git_src/org-mode/lisp/ox-icalendar hides
/usr/share/emacs/28.2/lisp/org/ox-icalendar
~/bin/git_src/org-mode/lisp/ox-man hides
/usr/share/emacs/28.2/lisp/org/ox-man
~/bin/git_src/org-mode/lisp/org-table hides
/usr/share/emacs/28.2/lisp/org/org-table
~/bin/git_src/org-mode/lisp/ob-lilypond hides
/usr/share/emacs/28.2/lisp/org/ob-lilypond
~/bin/git_src/org-mode/lisp/org-feed hides
/usr/share/emacs/28.2/lisp/org/org-feed
~/bin/git_src/org-mode/lisp/ob-ref hides
/usr/share/emacs/28.2/lisp/org/ob-ref
~/bin/git_src/org-mode/lisp/org-inlinetask hides
/usr/share/emacs/28.2/lisp/org/org-inlinetask
~/bin/git_src/org-mode/lisp/org-src hides
/usr/share/emacs/28.2/lisp/org/org-src
~/bin/git_src/org-mode/lisp/ob-awk hides
/usr/share/emacs/28.2/lisp/org/ob-awk
~/bin/git_src/org-mode/lisp/ob-screen hides
/usr/share/emacs/28.2/lisp/org/ob-screen
~/bin/git_src/org-mode/lisp/ol-w3m hides
/usr/share/emacs/28.2/lisp/org/ol-w3m
~/bin/git_src/org-mode/lisp/ob-julia hides
/usr/share/emacs/28.2/lisp/org/ob-julia
~/bin/git_src/org-mode/lisp/ob-scheme hides
/usr/share/emacs/28.2/lisp/org/ob-scheme
~/bin/git_src/org-mode/lisp/ob-java hides
/usr/share/emacs/28.2/lisp/org/ob-java
~/bin/git_src/org-mode/lisp/ox-texinfo hides
/usr/share/emacs/28.2/lisp/org/ox-texinfo
~/bin/git_src/org-mode/lisp/ol-rmail hides
/usr/share/emacs/28.2/lisp/org/ol-rmail
~/bin/git_src/org-mode/lisp/ob-haskell hides
/usr/share/emacs/28.2/lisp/org/ob-haskell
~/bin/git_src/org-mode/lisp/ob-R hides
/usr/share/emacs/28.2/lisp/org/ob-R
~/bin/git_src/org-mode/lisp/org-archive hides
/usr/share/emacs/28.2/lisp/org/org-archive
~/bin/git_src/org-mode/lisp/ob-dot hides
/usr/share/emacs/28.2/lisp/org/ob-dot
~/bin/git_src/org-mode/lisp/ob-ocaml hides
/usr/share/emacs/28.2/lisp/org/ob-ocaml
~/bin/git_src/org-mode/lisp/ob-lua hides
/usr/share/emacs/28.2/lisp/org/ob-lua
~/bin/git_src/org-mode/lisp/org-entities hides
/usr/share/emacs/28.2/lisp/org/org-entities
~/bin/git_src/org-mode/lisp/ob-processing hides
/usr/share/emacs/28.2/lisp/org/ob-processing
~/bin/git_src/org-mode/lisp/org-macro hides
/usr/share/emacs/28.2/lisp/org/org-macro
~/bin/git_src/org-mode/lisp/ob-python hides
/usr/share/emacs/28.2/lisp/org/ob-python
~/bin/git_src/org-mode/lisp/org-compat hides
/usr/share/emacs/28.2/lisp/org/org-compat
~/bin/git_src/org-mode/lisp/oc-biblatex hides
/usr/share/emacs/28.2/lisp/org/oc-biblatex
~/bin/git_src/org-mode/lisp/org-clock hides
/usr/share/emacs/28.2/lisp/org/org-clock
~/bin/git_src/org-mode/lisp/ox-beamer hides
/usr/share/emacs/28.2/lisp/org/ox-beamer
~/bin/git_src/org-mode/lisp/oc-basic hides
/usr/share/emacs/28.2/lisp/org/oc-basic
~/bin/git_src/org-mode/lisp/ol-mhe hides
/usr/share/emacs/28.2/lisp/org/ol-mhe
~/bin/git_src/org-mode/lisp/org-attach-git hides
/usr/share/emacs/28.2/lisp/org/org-attach-git
~/bin/git_src/org-mode/lisp/org-mobile hides
/usr/share/emacs/28.2/lisp/org/org-mobile
~/bin/git_src/org-mode/lisp/ox hides /usr/share/emacs/28.2/lisp/org/ox
~/bin/git_src/org-mode/lisp/ob-lisp hides
/usr/share/emacs/28.2/lisp/org/ob-lisp
~/bin/git_src/org-mode/lisp/ob-eval hides
/usr/share/emacs/28.2/lisp/org/ob-eval
~/bin/git_src/org-mode/lisp/org-refile hides
/usr/share/emacs/28.2/lisp/org/org-refile
~/bin/git_src/org-mode/lisp/ox-ascii hides
/usr/share/emacs/28.2/lisp/org/ox-ascii
~/bin/git_src/org-mode/lisp/org-colview hides
/usr/share/emacs/28.2/lisp/org/org-colview
~/bin/git_src/org-mode/lisp/ob-ruby hides
/usr/share/emacs/28.2/lisp/org/ob-ruby
~/bin/git_src/org-mode/lisp/ol-bbdb hides
/usr/share/emacs/28.2/lisp/org/ol-bbdb
~/bin/git_src/org-mode/lisp/ob-maxima hides
/usr/share/emacs/28.2/lisp/org/ob-maxima
~/bin/git_src/org-mode/lisp/org-crypt hides
/usr/share/emacs/28.2/lisp/org/org-crypt
~/bin/git_src/org-mode/lisp/ob-fortran hides
/usr/share/emacs/28.2/lisp/org/ob-fortran
~/bin/git_src/org-mode/lisp/org-timer hides
/usr/share/emacs/28.2/lisp/org/org-timer
~/bin/git_src/org-mode/lisp/ob-forth hides
/usr/share/emacs/28.2/lisp/org/ob-forth
~/bin/git_src/org-mode/lisp/ob-clojure hides
/usr/share/emacs/28.2/lisp/org/ob-clojure
~/bin/git_src/org-mode/lisp/org-loaddefs hides
/usr/share/emacs/28.2/lisp/org/org-loaddefs
~/bin/git_src/org-mode/lisp/ob-core hides
/usr/share/emacs/28.2/lisp/org/ob-core
~/bin/git_src/org-mode/lisp/ox-html hides
/usr/share/emacs/28.2/lisp/org/ox-html
~/bin/git_src/org-mode/lisp/org-protocol hides
/usr/share/emacs/28.2/lisp/org/org-protocol
~/bin/git_src/org-mode/lisp/ox-publish hides
/usr/share/emacs/28.2/lisp/org/ox-publish
~/bin/git_src/org-mode/lisp/org-datetree hides
/usr/share/emacs/28.2/lisp/org/org-datetree
~/bin/git_src/org-mode/lisp/ob-matlab hides
/usr/share/emacs/28.2/lisp/org/ob-matlab
~/bin/git_src/org-mode/lisp/ol-man hides
/usr/share/emacs/28.2/lisp/org/ol-man
~/bin/git_src/org-mode/lisp/ob-exp hides
/usr/share/emacs/28.2/lisp/org/ob-exp
~/bin/git_src/org-mode/lisp/ob-sass hides
/usr/share/emacs/28.2/lisp/org/ob-sass
~/bin/git_src/org-mode/lisp/ob-ditaa hides
/usr/share/emacs/28.2/lisp/org/ob-ditaa
~/bin/git_src/org-mode/lisp/ob-sql hides
/usr/share/emacs/28.2/lisp/org/ob-sql
~/bin/git_src/org-mode/lisp/ol-info hides
/usr/share/emacs/28.2/lisp/org/ol-info
~/bin/git_src/org-mode/lisp/ob-tangle hides
/usr/share/emacs/28.2/lisp/org/ob-tangle
~/bin/git_src/org-mode/lisp/ob-shell hides
/usr/share/emacs/28.2/lisp/org/ob-shell
~/bin/git_src/org-mode/lisp/ol-eshell hides
/usr/share/emacs/28.2/lisp/org/ol-eshell
~/bin/git_src/org-mode/lisp/ob-eshell hides
/usr/share/emacs/28.2/lisp/org/ob-eshell
~/bin/git_src/org-mode/lisp/ob-table hides
/usr/share/emacs/28.2/lisp/org/ob-table
~/bin/git_src/org-mode/lisp/org-mouse hides
/usr/share/emacs/28.2/lisp/org/org-mouse
~/bin/git_src/org-mode/lisp/org-keys hides
/usr/share/emacs/28.2/lisp/org/org-keys
~/bin/git_src/org-mode/lisp/org hides
/usr/share/emacs/28.2/lisp/org/org
~/bin/git_src/org-mode/lisp/ob-sqlite hides
/usr/share/emacs/28.2/lisp/org/ob-sqlite
~/bin/git_src/org-mode/lisp/ob-emacs-lisp hides
/usr/share/emacs/28.2/lisp/org/ob-emacs-lisp
~/bin/git_src/org-mode/lisp/ol-doi hides
/usr/share/emacs/28.2/lisp/org/ol-doi
~/bin/git_src/org-mode/lisp/ob-octave hides
/usr/share/emacs/28.2/lisp/org/ob-octave
~/bin/git_src/org-mode/lisp/ob-gnuplot hides
/usr/share/emacs/28.2/lisp/org/ob-gnuplot
~/bin/git_src/org-mode/lisp/ol-docview hides
/usr/share/emacs/28.2/lisp/org/ol-docview
~/bin/git_src/org-mode/lisp/org-element hides
/usr/share/emacs/28.2/lisp/org/org-element
~/bin/git_src/org-mode/lisp/ob-calc hides
/usr/share/emacs/28.2/lisp/org/ob-calc
~/bin/git_src/org-mode/lisp/ol-bibtex hides
/usr/share/emacs/28.2/lisp/org/ol-bibtex
~/bin/git_src/org-mode/lisp/ob-groovy hides
/usr/share/emacs/28.2/lisp/org/ob-groovy
~/bin/git_src/org-mode/lisp/oc hides /usr/share/emacs/28.2/lisp/org/oc
~/bin/git_src/org-mode/lisp/org-macs hides
/usr/share/emacs/28.2/lisp/org/org-macs
~/bin/git_src/org-mode/lisp/ox-md hides
/usr/share/emacs/28.2/lisp/org/ox-md
~/bin/git_src/org-mode/lisp/ob-perl hides
/usr/share/emacs/28.2/lisp/org/ob-perl
~/bin/git_src/org-mode/lisp/org-plot hides
/usr/share/emacs/28.2/lisp/org/org-plot
~/bin/git_src/org-mode/lisp/ob-comint hides
/usr/share/emacs/28.2/lisp/org/ob-comint
~/bin/git_src/org-mode/lisp/ox-odt hides
/usr/share/emacs/28.2/lisp/org/ox-odt
~/bin/git_src/org-mode/lisp/org-footnote hides
/usr/share/emacs/28.2/lisp/org/org-footnote
~/bin/git_src/org-mode/lisp/org-version hides
/usr/share/emacs/28.2/lisp/org/org-version
~/bin/git_src/org-mode/lisp/ol-irc hides
/usr/share/emacs/28.2/lisp/org/ol-irc
~/bin/git_src/org-mode/lisp/org-habit hides
/usr/share/emacs/28.2/lisp/org/org-habit
~/bin/git_src/org-mode/lisp/org-id hides
/usr/share/emacs/28.2/lisp/org/org-id
~/bin/git_src/org-mode/lisp/oc-natbib hides
/usr/share/emacs/28.2/lisp/org/oc-natbib
~/bin/git_src/org-mode/lisp/ob-C hides
/usr/share/emacs/28.2/lisp/org/ob-C
~/bin/git_src/org-mode/lisp/ob-sed hides
/usr/share/emacs/28.2/lisp/org/ob-sed
~/bin/git_src/org-mode/lisp/ob-js hides
/usr/share/emacs/28.2/lisp/org/ob-js
~/bin/git_src/org-mode/lisp/org-capture hides
/usr/share/emacs/28.2/lisp/org/org-capture
/usr/share/emacs/site-lisp/latex-cjk-thai/thai-word hides
/usr/share/emacs/28.2/lisp/language/thai-word

Features:
(shadow sort mail-extr emacsbug sendmail comp comp-cstr warnings
mule-util cal-move ox-jira ox-odt rng-loc rng-uri rng-parse rng-match
rng-dt rng-util rng-pttrn nxml-parse nxml-ns nxml-enc xmltok nxml-util
ox-latex ox-icalendar org-agenda ox-html table ox-ascii ox-publish ox
face-remap org-indent oc-basic org-element org-persist org-id org-
refile
avl-tree ol-eww eww xdg url-queue thingatpt mm-url ol-rmail ol-mhe
ol-irc ol-info ol-gnus nnselect gnus-search eieio-opt speedbar ezimage
dframe gnus-art mm-uu mml2015 mm-view mml-smime smime dig ol-docview
doc-view jka-compr image-mode exif ol-bibtex bibtex ol-bbdb ol-w3m
ol-doi org-link-doi cus-edit pp cus-start cus-load ob-scheme ob-java
ob-C cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align
cc-engine cc-vars cc-defs ob-python python tramp-sh tramp tramp-
loaddefs
trampver tramp-integration files-x tramp-compat shell ls-lisp org ob
ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src sh-script
smie
executable ob-comint org-pcomplete pcomplete org-list org-footnote
org-faces org-entities noutline outline ob-emacs-lisp ob-core ob-eval
org-cycle org-table ol org-fold org-fold-core org-keys oc
org-element-ast inline org-loaddefs find-func cal-menu calendar
cal-loaddefs gnus-sum shr kinsoku svg dom gnus-group gnus-undo
gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7
netrc nnoo parse-time iso8601 gnus-spec gnus-int gnus-range message rmc
puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068
epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader gnus-win gnus nnheader gnus-util rmail
rmail-loaddefs rfc2047 rfc2045 ietf-drums time-date mail-utils mm-util
mail-prsvr org-version org-compat org-macs rx pcase format-spec
geiser-mit geiser-repl geiser-image geiser-capf geiser-doc geiser-menu
geiser-autodoc info-look compile text-property-search geiser-edit etags
fileloop generator xref project geiser-completion geiser-eval
geiser-connection tq geiser-syntax scheme geiser-impl help-fns
radix-tree geiser-log comint ansi-color geiser-popup view geiser-custom
geiser-base ring geiser cl-extra help-mode edmacro kmacro recentf
tree-widget wid-edit hl-line display-line-numbers use-package
use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key easy-mmode use-package-core finder-inf
tree-sitter-autoloads tsc-autoloads info package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-
dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax 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 emoji-zwj
charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 1254057 127037)
 (symbols 48 44625 1)
 (strings 32 220341 4254)
 (string-bytes 1 6472679)
 (vectors 16 63534)
 (vector-slots 8 1808150 192098)
 (floats 8 388 279)
 (intervals 56 8917 72)
 (buffers 992 19))






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

* bug#71323: 28.2; global-display-line-numbers-mode in org file do strange identation when headers are folded
  2024-06-02  9:10 bug#71323: 28.2; global-display-line-numbers-mode in org file do strange identation when headers are folded Mikhail Efremov
@ 2024-06-02 12:20 ` Eli Zaretskii
       [not found]   ` <588dc873eff0f9fc9ecbd78766288ed213b3089a.camel@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2024-06-02 12:20 UTC (permalink / raw)
  To: Mikhail Efremov; +Cc: 71323

tags 71323 notabug
thanks

> From: Mikhail Efremov <jakutenshi@gmail.com>
> Date: Sun, 02 Jun 2024 15:10:46 +0600
> 
> * Description
> 
> There is an issue with not so large org files with
> global-display-line-numbers-mode is toggled on. You may reproduce it:
> 
> 1. ~emacs -Q~
> 2. open an org file with 1000+ lines of different headers' layers
> unfolded.
> 3. ~M-x global-display-line-numbers-mode~
> 4. Check that unfolded headers on lines 999-1000 are indented fine:
>   - numbers are right-aligned;
>   - same-level headers are indented equally with the same indent width
>   relative to line numbers.
> 5. Fold all headers with the property: on the screen of the buffer
> there
> are single-, two- and three-digits lines' numbers are presented.
> 
> Then, you should see the picture like this:
> 
>   1 * header1
>  24 * header2
> 132 * header3
> 1019 * header4
> 
> The same behavior is on ~emacs -nw -Q~.
> 
> The issue is valid also on built from sources emacs: GNU Emacs 29.3
> (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version
> 1.16.0) of 2024-04-08
> 
> * Motivation
> 
> This behavior on the one hand constantly shifts
> left-to-right-and-vice-versa the buffer's text and also confuses with
> headers' identation level.
> 
> * Definition of Done
> 
> After the steps of reproducing the desired view is:
>    1 * header1
>   24 * header2
>  132 * header3
> 1019 * header4

You should be able to have this if you customize
display-line-numbers-width-start to a non-nil value.  Consider also
customizing display-line-numbers-grow-only to a non-nil value.

> * Details of implementation
> 
> I guess there is a problem with line's mode algorithm, from my side
> it looks like it taking into account only 1 digit difference for an
> identation, then if there is 2 or more digits differnece, then all
> after the first-digit diff identations are broken.

No, that's not what happens.  The problem is that the required width
of the line-number display needs to be calculated when the window is
about to be shown on display or redisplayed due to scrolling etc.  At
that time, the display-engine code which does this calculation cannot
know up front how many lines are hidden by 'invisible' text properties
and overlays, something that Org uses a lot, and therefore cannot
correctly estimate the largest line number to be shown.  So its
estimation of the maximum number of the line in the window are
incorrect in those cases.

Customizing display-line-numbers-width-start fixes that problem, for a
price of a slightly slower initial display of the window.  It could
still fail if you add a lot of lines to the buffer, in which case
toggling display-line-numbers-mode off and on again should fix it.

> The posible solution is to count total lines number and reserving
> line's numbers side width from total lines count number's width.

That's exactly what the above user option does, when non-nil.

There's no bug here.





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

* bug#71323: 28.2; global-display-line-numbers-mode in org file do strange identation when headers are folded
       [not found]   ` <588dc873eff0f9fc9ecbd78766288ed213b3089a.camel@gmail.com>
@ 2024-06-04 14:49     ` Eli Zaretskii
  2024-06-30  6:10       ` Stefan Kangas
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2024-06-04 14:49 UTC (permalink / raw)
  To: Mikhail Efremov; +Cc: 71323

> From: Mikhail Efremov <jakutenshi@gmail.com>
> Date: Tue, 04 Jun 2024 14:04:33 +0600
> 
> Hi,
> 
> Thank you a lot, the combination of the follows solved my problem:
> 
> (setq display-line-numbers-width-start 6)
> (setq display-line-numbers-grow-only t)
> 
> Again, thank you for suggestions!
> Happy emacsing~

Thanks, so I'm closing this bug.





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

* bug#71323: 28.2; global-display-line-numbers-mode in org file do strange identation when headers are folded
  2024-06-04 14:49     ` Eli Zaretskii
@ 2024-06-30  6:10       ` Stefan Kangas
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Kangas @ 2024-06-30  6:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Mikhail Efremov, 71323-done

Eli Zaretskii <eliz@gnu.org> writes:

> Thanks, so I'm closing this bug.

Really closing.





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

end of thread, other threads:[~2024-06-30  6:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-02  9:10 bug#71323: 28.2; global-display-line-numbers-mode in org file do strange identation when headers are folded Mikhail Efremov
2024-06-02 12:20 ` Eli Zaretskii
     [not found]   ` <588dc873eff0f9fc9ecbd78766288ed213b3089a.camel@gmail.com>
2024-06-04 14:49     ` Eli Zaretskii
2024-06-30  6:10       ` 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).