* bug#75168: 31.0.50; text-scale confuses ruler-mode when display-line-number-mode is active @ 2024-12-28 21:15 Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-12-29 6:37 ` Eli Zaretskii 0 siblings, 1 reply; 7+ messages in thread From: Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-28 21:15 UTC (permalink / raw) To: 75168 [-- Attachment #1: Type: text/plain, Size: 12535 bytes --] Reproduction steps: 1. emacs -Q 2. M-x display-line-numbers-mode RET 3. M-x ruler-mode RET 4. C-x C-+ C-+ C-+ C-+ You should notice that the ruler is misaligned. I've hotfixed this in my running Emacs by applying: modified lisp/ruler-mode.el @@ -636,7 +636,7 @@ ruler-mode-ruler ;; FIXME: ruler-mode relies on I being an integer, so ;; the column numbers might be slightly off if the ;; line-number face is customized. - (round (line-number-display-width 'columns)) + (+ (round (line-number-display-width)) 2) 0)) (j (ruler-mode-text-scaled-window-hscroll)) ;; Setup the scrollbar, fringes, and margins areas. ... and re-evaling the ruler-mode-ruler defun. Per the line-number-display-width doc, when it is called with 'columns, it returns the number of columns in the frames canonical font size, but that's not the font size that is used for the fringes: the fringes seem to use the font the buffer is using, at least after text-scale-mode does its thing. (+ ... 2) was not chosen at random, padding is specified as 2 as by the docstring of line-number-display-width. Interestingly, changing text-scale-remap-header-line appears to have no effect, but that variable ought to be accounted for somehow also, I think? Though, if the line-numbers and header line always use the same face, then the above should be correct, I think? Anyway, thanks in advance, have a lovely day and happy holidays! (PS: I can confirm this happens on PGTK too also) In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.18.2, Xaw3d scroll bars) of 2024-12-28 built on localhost Repository revision: 72eb5f8bedbe441f6a3952557b9aa3ef6fd6235d Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12401004 System Description: Gentoo GNU/Linux Configured using: 'configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --datarootdir=/usr/share --disable-silent-rules --docdir=/usr/share/doc/emacs-31.0.9999 --htmldir=/usr/share/doc/emacs-31.0.9999/html --libdir=/usr/lib64 --program-suffix=-emacs-31-vcs --includedir=/usr/include/emacs-31-vcs --infodir=/usr/share/info/emacs-31-vcs --localstatedir=/var --enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp --without-compress-install --without-hesiod --without-pop --with-file-notification=inotify --with-pdumper --enable-acl --enable-xattr --with-dbus --with-modules --with-gameuser=:gamestat --with-libgmp --with-gpm --with-native-compilation=aot --without-kerberos --without-kerberos5 --with-lcms2 --with-xml2 --with-mailutils --without-selinux --with-sqlite3 --with-gnutls --with-libsystemd --with-threads --with-tree-sitter --without-wide-int --with-sound=alsa --with-zlib --with-x --without-pgtk --without-ns --without-gconf --without-gsettings --with-toolkit-scroll-bars --with-xpm --with-xft --with-cairo --with-harfbuzz --with-libotf --with-m17n-flt --with-x-toolkit=lucid --with-xaw3d --with-gif --with-jpeg --with-png --with-rsvg --with-tiff --with-webp --without-imagemagick --with-dumping=pdumper 'CFLAGS=-freport-bug -O2 -ggdb3 -pipe -fdiagnostics-color=always -march=x86-64-v2 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -fuse-ld=mold -Wl,--undefined-version -fno-fast-math -ffp-contract=off' CPPFLAGS= 'LDFLAGS=-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -O2 -Wl,-O3 -pipe -fdiagnostics-color=always -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,-z,pack-relative-relocs -Wl,--build-id -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -fuse-ld=mold -Wl,--undefined-version'' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM HARFBUZZ JPEG LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XAW3D XDBE XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LC_TIME: en_GB.UTF-8 value of $LANG: en_US.utf8 locale-coding-system: utf-8-unix Major mode: ELisp/l Minor modes in effect: bug-reference-prog-mode: t global-git-commit-mode: t magit-auto-revert-mode: t auto-revert-mode: t server-mode: t dape-breakpoint-global-mode: t hexl-follow-ascii: t gdb-many-windows: t global-jinx-mode: t jinx-mode: t paredit-mode: t display-line-numbers-mode: t ruler-mode: t indent-bars-mode: t diff-hl-flydiff-mode: t diff-hl-mode: t hl-todo-mode: t savehist-mode: t save-place-mode: t global-hl-line-mode: t mu4e-modeline-mode: t ws-butler-global-mode: t ws-butler-mode: t corfu-popupinfo-mode: t global-corfu-mode: t corfu-mode: t marginalia-mode: t vertico-mouse-mode: t vertico-mode: t org-roam-db-autosync-mode: t which-key-mode: t global-undo-tree-mode: t undo-tree-mode: t global-display-fill-column-indicator-mode: t display-fill-column-indicator-mode: t which-function-mode: t electric-pair-mode: t global-whitespace-mode: t whitespace-mode: t repeat-mode: t override-global-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tab-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 minibuffer-regexp-mode: t column-number-mode: t line-number-mode: t auto-fill-function: do-auto-fill transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: /usr/share/emacs/site-lisp/emacs-eat/eat hides /usr/share/emacs/site-lisp/emacs-eat/term/eat /usr/share/emacs/site-lisp/which-key/which-key hides /usr/share/emacs/31.0.50/lisp/which-key /usr/share/emacs/site-lisp/transient/transient hides /usr/share/emacs/31.0.50/lisp/transient /usr/share/emacs/site-lisp/compat/compat hides /usr/share/emacs/31.0.50/lisp/emacs-lisp/compat Features: (shadow sort mail-extr emacsbug vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs forge-repos forge-tablist forge-topics forge-commands forge-semi forge-bitbucket buck forge-gogs gogs forge-gitea gtea forge-gitlab glab forge-github ghub-graphql treepy gsexp ghub url-http url-gw nsm url-auth let-alist forge-notify forge-revnote forge-pullreq forge-issue forge-topic yaml eieio-custom bug-reference forge-post forge-repo forge forge-core forge-db closql eieio-base magit-bookmark git-rebase magit-extras magit-sparse-checkout magit-gitignore magit-ediff ediff ediff-merg ediff-mult ediff-wind ediff-diff ediff-help ediff-init ediff-util magit-subtree magit-patch magit-submodule magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit package url-handlers magit-repos magit-apply magit-wip magit-log magit-diff smerge-mode git-commit magit-core magit-autorevert autorevert magit-margin magit-transient magit-process with-editor server magit-mode transient benchmark magit-git magit-base crm gitignore-mode cl-print mode-local shortdoc conf-mode misearch multi-isearch eldoc-box tabify apropos help-fns radix-tree consult-xref consult dape hexl gdb-mi bindat gud pulse eglot external-completion jsonrpc xref flymake project ert debug backtrace filenotify pcase vc-git ebuild-mode skeleton cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs tramp-archive tramp-gvfs vertico-directory jinx paredit display-line-numbers ruler-mode indent-bars-ts indent-bars cus-edit cus-start face-remap diff-hl-flydiff diff-hl log-view log-edit add-log pcvs-util vc-dir ewoc vc vc-dispatcher diff-mode track-changes hl-todo savehist saveplace tramp-cache time-stamp tramp-sh tramp trampver tramp-integration files-x tramp-message tramp-compat shell tramp-loaddefs desktop frameset mu4e mu4e-org mu4e-notification notifications mu4e-main smtpmail mu4e-view mu4e-mime-parts mu4e-headers mu4e-thread mu4e-actions mu4e-compose mu4e-draft gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig gnus-sum gnus-group gnus-undo gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 nnoo parse-time iso8601 gnus-spec gnus-int gnus-range gnus-win gnus nnheader range wid-edit mu4e-search mu4e-lists mu4e-bookmarks mu4e-mark mu4e-message shr pixel-fill kinsoku url-file browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie generate-lisp-file url-domsuf url-util flow-fill mule-util hl-line mu4e-contacts mu4e-update mu4e-folders mu4e-context mu4e-query-items mu4e-server mu4e-modeline mu4e-vars mu4e-helpers mu4e-config mu4e-window bookmark pp ido message sendmail mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader mu4e-obsolete auth-source-pass ws-butler modus-vivendi-tinted-theme modus-themes kind-icon svg-lib svg dom corfu-popupinfo corfu orderless marginalia vertico-mouse vertico flycheck lisp-mnt emacsql-sqlite-builtin sqlite comp comp-cstr warnings org-roam-migrate org-roam-log org-roam-mode org-roam-capture org-roam-id org-roam-node org-roam-db org-roam-utils org-roam-compat org-roam org-capture org-element org-persist xdg avl-tree generator org-attach org-id org-refile org-element-ast inline org-clock dbus comp-run comp-common xml org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src sh-script smie treesit executable ob-comint org-pcomplete pcomplete org-list org-footnote org-faces org-entities time-date org-version ob-emacs-lisp ob-core ob-eval org-cycle org-table ol org-fold org-fold-core org-keys oc org-loaddefs find-func cal-menu calendar cal-loaddefs org-compat org-macs emacsql-sqlite emacsql emacsql-compiler magit-section format-spec cursor-sensor compat dash cus-load which-key ace-window avy undo-tree diff queue display-fill-column-indicator which-func imenu elec-pair whitespace markdown-mode edit-indirect rx color url-parse auth-source eieio eieio-core password-cache json map url-vars thingatpt noutline outline icons repeat edmacro kmacro byte-opt cl-macs gv cl-extra help-mode cl-seq use-package use-package-ensure use-package-delight use-package-diminish use-package-bind-key bind-key easy-mmode use-package-core bytecomp byte-compile site-gentoo hs-lint compile text-property-search comint subr-x ansi-osc ansi-color ring preview-latex mmm-auto mmm-vars cl-loaddefs cl-lib mmm-utils mmm-compat ess-autoloads tex-site rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd touch-screen 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 nadvice seq simple cl-generic indonesian philippine 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 abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting font-render-setting cairo x-toolkit xinput2 x multi-tty move-toolbar make-network-process tty-child-frames native-compile emacs) Memory information: ((conses 16 1040853 1313847) (symbols 48 62998 13) (strings 32 266037 45947) (string-bytes 1 9930584) (vectors 16 135323) (vector-slots 8 1617094 644306) (floats 8 1081 2806) (intervals 56 23296 18638) (buffers 992 54)) -- Arsen Arsenović [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 381 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#75168: 31.0.50; text-scale confuses ruler-mode when display-line-number-mode is active 2024-12-28 21:15 bug#75168: 31.0.50; text-scale confuses ruler-mode when display-line-number-mode is active Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-29 6:37 ` Eli Zaretskii 2024-12-29 12:06 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors 0 siblings, 1 reply; 7+ messages in thread From: Eli Zaretskii @ 2024-12-29 6:37 UTC (permalink / raw) To: Arsen Arsenović; +Cc: 75168 > Date: Sat, 28 Dec 2024 22:15:28 +0100 > From: Arsen Arsenović via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> > > Reproduction steps: > 1. emacs -Q > 2. M-x display-line-numbers-mode RET > 3. M-x ruler-mode RET > 4. C-x C-+ C-+ C-+ C-+ > > You should notice that the ruler is misaligned. Ruler mode doesn't work well with text-scale, as the comment there says. > I've hotfixed this in my running Emacs by applying: > > modified lisp/ruler-mode.el > @@ -636,7 +636,7 @@ ruler-mode-ruler > ;; FIXME: ruler-mode relies on I being an integer, so > ;; the column numbers might be slightly off if the > ;; line-number face is customized. > - (round (line-number-display-width 'columns)) > + (+ (round (line-number-display-width)) 2) > 0)) > (j (ruler-mode-text-scaled-window-hscroll)) > ;; Setup the scrollbar, fringes, and margins areas. > > ... and re-evaling the ruler-mode-ruler defun. > > Per the line-number-display-width doc, when it is called with 'columns, > it returns the number of columns in the frames canonical font size, but > that's not the font size that is used for the fringes: the fringes seem > to use the font the buffer is using, at least after text-scale-mode does > its thing. I'm not sure I understand what you mean by "fringes seem to use the font the buffer is using". When I type "C-x C-+ C-+...", the fringes stay at their original width. Do you see something different? Anyway, the change you suggest is basically going back to what we had before fixing bug#28855, so I don't think we can make such a change, at least not literally. We need something more complex to account for the use cases described in that bug. > Interestingly, changing text-scale-remap-header-line appears to have no > effect, but that variable ought to be accounted for somehow also, I > think? Though, if the line-numbers and header line always use the same > face, then the above should be correct, I think? If you take a look at ruler-mode.el, you will see that it overrides header-line-format by its own code. ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#75168: 31.0.50; text-scale confuses ruler-mode when display-line-number-mode is active 2024-12-29 6:37 ` Eli Zaretskii @ 2024-12-29 12:06 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors 2025-01-11 13:16 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors 0 siblings, 1 reply; 7+ messages in thread From: Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-29 12:06 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 75168 [-- Attachment #1.1: Type: text/plain, Size: 1838 bytes --] Eli Zaretskii <eliz@gnu.org> writes: >> Date: Sat, 28 Dec 2024 22:15:28 +0100 >> From: Arsen Arsenović via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> >> >> Reproduction steps: >> 1. emacs -Q >> 2. M-x display-line-numbers-mode RET >> 3. M-x ruler-mode RET >> 4. C-x C-+ C-+ C-+ C-+ >> >> You should notice that the ruler is misaligned. > > Ruler mode doesn't work well with text-scale, as the comment there says. > >> I've hotfixed this in my running Emacs by applying: >> >> modified lisp/ruler-mode.el >> @@ -636,7 +636,7 @@ ruler-mode-ruler >> ;; FIXME: ruler-mode relies on I being an integer, so >> ;; the column numbers might be slightly off if the >> ;; line-number face is customized. >> - (round (line-number-display-width 'columns)) >> + (+ (round (line-number-display-width)) 2) >> 0)) >> (j (ruler-mode-text-scaled-window-hscroll)) >> ;; Setup the scrollbar, fringes, and margins areas. >> >> ... and re-evaling the ruler-mode-ruler defun. >> >> Per the line-number-display-width doc, when it is called with 'columns, >> it returns the number of columns in the frames canonical font size, but >> that's not the font size that is used for the fringes: the fringes seem >> to use the font the buffer is using, at least after text-scale-mode does >> its thing. > > I'm not sure I understand what you mean by "fringes seem to use the > font the buffer is using". When I type "C-x C-+ C-+...", the fringes > stay at their original width. Do you see something different? Hm, yes, fringe might be the wrong word. I am referring to the column where the ruler and line number are, which I've outlined in red: [-- Attachment #1.2: Red boxes represent what I was referring to --] [-- Type: image/png, Size: 54405 bytes --] [-- Attachment #1.3: Type: text/plain, Size: 3162 bytes --] Sorry about the confusion. That part of the display appears to use the same font size as the buffer after text-scale has been enabled. > Anyway, the change you suggest is basically going back to what we had > before fixing bug#28855, so I don't think we can make such a change, > at least not literally. We need something more complex to account for > the use cases described in that bug. Yes, I had a feeling what I posted was not correct, because it seemed like the "obvious" thing, and so, would've been there already if correct. I've just dug through the Elisp manual a little and I think (elisp) Specified Space is precisely what's needed here. I've tried the following: modified lisp/ruler-mode.el @@ -632,12 +632,7 @@ ruler-mode-ruler (let* ((w (ruler-mode-text-scaled-window-width)) (m (window-margins)) (f (window-fringes)) - (i (if display-line-numbers - ;; FIXME: ruler-mode relies on I being an integer, so - ;; the column numbers might be slightly off if the - ;; line-number face is customized. - (round (line-number-display-width 'columns)) - 0)) + (i 0) (j (ruler-mode-text-scaled-window-hscroll)) ;; Setup the scrollbar, fringes, and margins areas. (lf (ruler-mode-space @@ -739,7 +734,13 @@ ruler-mode-ruler (setq i (1+ i) j (1+ j))) - (let ((ruler-str (concat ruler)) + (let ((ruler-indent + (if (not display-line-numbers) + "" + (propertize " " 'display + `(space :width + (,(- (line-number-display-width t) 1)))))) + (ruler-str (concat ruler)) (len (length ruler))) (add-text-properties 0 len ruler-wide-props ruler-str) (dolist (p (nreverse props)) @@ -747,13 +748,14 @@ ruler-mode-ruler ;; Return the ruler propertized string. Using list here, ;; instead of concat visually separate the different areas. - (if (nth 2 (window-fringes)) - ;; fringes outside margins. - (list "" (and (eq 'left sbvt) sb) lf lm - ruler-str rm rf (and (eq 'right sbvt) sb)) - ;; fringes inside margins. - (list "" (and (eq 'left sbvt) sb) lm lf - ruler-str rf rm (and (eq 'right sbvt) sb)))))) + (let ((ruler-str-ind (concat ruler-indent ruler-str))) + (if (nth 2 (window-fringes)) + ;; fringes outside margins. + (list "" (and (eq 'left sbvt) sb) lf lm + ruler-str-ind rm rf (and (eq 'right sbvt) sb)) + ;; fringes inside margins. + (list "" (and (eq 'left sbvt) sb) lm lf + ruler-str-ind rf rm (and (eq 'right sbvt) sb))))))) (provide 'ruler-mode) This is almost perfect. The (- ... 1) in the :width pixel spec is obviously a hack (and breaks this patch in emacs -nw). I have no idea why an extra pixel is inserted in GUI mode. If you apply the above but remove (- ... 1), you'll see the following: [-- Attachment #1.4: Screen, zoomed in using GIMP. The crosshair position is an extra column of pixels --] [-- Type: image/png, Size: 7323 bytes --] [-- Attachment #1.5: Type: text/plain, Size: 1300 bytes --] The above is a screenshot of Emacs with the patch applied opened in GIMP and zoomed in very far. I've placed the crosshair on the problematic pixel column. If you know why that happens, this could constitute a fix with that tweak applied. Just using :align-to header-line-indent-width appears to have even worse results, because ISTM that it gets rounded after scaling is applied, so it is of the wrong width by different amounts for each text-scale. Even without any text-scale applied, it has the same extra-pixel problem. I think the above is close to correct, though, it perhaps implies that header-line-indent-mode should get some love in order to be pixel-perfect in pixel specifications too. >> Interestingly, changing text-scale-remap-header-line appears to have no >> effect, but that variable ought to be accounted for somehow also, I >> think? Though, if the line-numbers and header line always use the same >> face, then the above should be correct, I think? > > If you take a look at ruler-mode.el, you will see that it overrides > header-line-format by its own code. Yes, but the name and logic in text-scale seemed to imply to me that text-scale would take the header-line-format set up by ruler-mode and "alter" it somehow. -- Arsen Arsenović [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 381 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#75168: 31.0.50; text-scale confuses ruler-mode when display-line-number-mode is active 2024-12-29 12:06 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2025-01-11 13:16 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors 2025-01-18 9:58 ` Eli Zaretskii 0 siblings, 1 reply; 7+ messages in thread From: Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2025-01-11 13:16 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 75168 [-- Attachment #1: Type: text/plain, Size: 4370 bytes --] Hi, Arsen Arsenović <arsen@aarsen.me> writes: > I've just dug through the Elisp manual a little and I think (elisp) > Specified Space is precisely what's needed here. I've tried the > following: > > modified lisp/ruler-mode.el > @@ -632,12 +632,7 @@ ruler-mode-ruler > (let* ((w (ruler-mode-text-scaled-window-width)) > (m (window-margins)) > (f (window-fringes)) > - (i (if display-line-numbers > - ;; FIXME: ruler-mode relies on I being an integer, so > - ;; the column numbers might be slightly off if the > - ;; line-number face is customized. > - (round (line-number-display-width 'columns)) > - 0)) > + (i 0) > (j (ruler-mode-text-scaled-window-hscroll)) > ;; Setup the scrollbar, fringes, and margins areas. > (lf (ruler-mode-space > @@ -739,7 +734,13 @@ ruler-mode-ruler > (setq i (1+ i) > j (1+ j))) > > - (let ((ruler-str (concat ruler)) > + (let ((ruler-indent > + (if (not display-line-numbers) > + "" > + (propertize " " 'display > + `(space :width > + (,(- (line-number-display-width t) 1)))))) > + (ruler-str (concat ruler)) > (len (length ruler))) > (add-text-properties 0 len ruler-wide-props ruler-str) > (dolist (p (nreverse props)) > @@ -747,13 +748,14 @@ ruler-mode-ruler > > ;; Return the ruler propertized string. Using list here, > ;; instead of concat visually separate the different areas. > - (if (nth 2 (window-fringes)) > - ;; fringes outside margins. > - (list "" (and (eq 'left sbvt) sb) lf lm > - ruler-str rm rf (and (eq 'right sbvt) sb)) > - ;; fringes inside margins. > - (list "" (and (eq 'left sbvt) sb) lm lf > - ruler-str rf rm (and (eq 'right sbvt) sb)))))) > + (let ((ruler-str-ind (concat ruler-indent ruler-str))) > + (if (nth 2 (window-fringes)) > + ;; fringes outside margins. > + (list "" (and (eq 'left sbvt) sb) lf lm > + ruler-str-ind rm rf (and (eq 'right sbvt) sb)) > + ;; fringes inside margins. > + (list "" (and (eq 'left sbvt) sb) lm lf > + ruler-str-ind rf rm (and (eq 'right sbvt) sb))))))) > > (provide 'ruler-mode) > > This is almost perfect. The (- ... 1) in the :width pixel spec is > obviously a hack (and breaks this patch in emacs -nw). I have no idea > why an extra pixel is inserted in GUI mode. If you apply the above but > remove (- ... 1), you'll see the following: [...] I've refined the patch: diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el index 003dcae560f..64568e06cc9 100644 --- a/lisp/ruler-mode.el +++ b/lisp/ruler-mode.el @@ -632,12 +632,7 @@ ruler-mode-ruler (let* ((w (ruler-mode-text-scaled-window-width)) (m (window-margins)) (f (window-fringes)) - (i (if display-line-numbers - ;; FIXME: ruler-mode relies on I being an integer, so - ;; the column numbers might be slightly off if the - ;; line-number face is customized. - (round (line-number-display-width 'columns)) - 0)) + (i 0) (j (ruler-mode-text-scaled-window-hscroll)) ;; Setup the scrollbar, fringes, and margins areas. (lf (ruler-mode-space @@ -745,6 +740,12 @@ ruler-mode-ruler (dolist (p (nreverse props)) (add-text-properties (nth 0 p) (nth 1 p) (nthcdr 2 p) ruler-str)) + ;; Attach an alignment indent. + (if display-line-numbers + (setq ruler-str + (concat (ruler-mode-space `(,(line-number-display-width t))) + ruler-str))) + ;; Return the ruler propertized string. Using list here, ;; instead of concat visually separate the different areas. (if (nth 2 (window-fringes)) This works perfectly on PGTK (and with -nw) - that extra pixel I mentioned seems to be an artifact, or perhaps a bug, of the Lucid toolkit. What do you think of the above? Have a lovely day. -- Arsen Arsenović [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 381 bytes --] ^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#75168: 31.0.50; text-scale confuses ruler-mode when display-line-number-mode is active 2025-01-11 13:16 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2025-01-18 9:58 ` Eli Zaretskii 2025-01-18 15:45 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors 0 siblings, 1 reply; 7+ messages in thread From: Eli Zaretskii @ 2025-01-18 9:58 UTC (permalink / raw) To: Arsen Arsenović; +Cc: 75168 > From: Arsen Arsenović <arsen@aarsen.me> > Cc: 75168@debbugs.gnu.org > Date: Sat, 11 Jan 2025 14:16:24 +0100 > > > This is almost perfect. The (- ... 1) in the :width pixel spec is > > obviously a hack (and breaks this patch in emacs -nw). I have no idea > > why an extra pixel is inserted in GUI mode. If you apply the above but > > remove (- ... 1), you'll see the following: [...] > > I've refined the patch: > > diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el > index 003dcae560f..64568e06cc9 100644 > --- a/lisp/ruler-mode.el > +++ b/lisp/ruler-mode.el > @@ -632,12 +632,7 @@ ruler-mode-ruler > (let* ((w (ruler-mode-text-scaled-window-width)) > (m (window-margins)) > (f (window-fringes)) > - (i (if display-line-numbers > - ;; FIXME: ruler-mode relies on I being an integer, so > - ;; the column numbers might be slightly off if the > - ;; line-number face is customized. > - (round (line-number-display-width 'columns)) > - 0)) > + (i 0) > (j (ruler-mode-text-scaled-window-hscroll)) > ;; Setup the scrollbar, fringes, and margins areas. > (lf (ruler-mode-space > @@ -745,6 +740,12 @@ ruler-mode-ruler > (dolist (p (nreverse props)) > (add-text-properties (nth 0 p) (nth 1 p) (nthcdr 2 p) ruler-str)) > > + ;; Attach an alignment indent. > + (if display-line-numbers > + (setq ruler-str > + (concat (ruler-mode-space `(,(line-number-display-width t))) > + ruler-str))) > + > ;; Return the ruler propertized string. Using list here, > ;; instead of concat visually separate the different areas. > (if (nth 2 (window-fringes)) > > This works perfectly on PGTK (and with -nw) - that extra pixel I > mentioned seems to be an artifact, or perhaps a bug, of the Lucid > toolkit. > > What do you think of the above? Seems to work well, so could you please submit a full patch with the commit log message, so we could then install this? Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#75168: 31.0.50; text-scale confuses ruler-mode when display-line-number-mode is active 2025-01-18 9:58 ` Eli Zaretskii @ 2025-01-18 15:45 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors 2025-01-18 15:54 ` Eli Zaretskii 0 siblings, 1 reply; 7+ messages in thread From: Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2025-01-18 15:45 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 75168 [-- Attachment #1.1: Type: text/plain, Size: 193 bytes --] Eli Zaretskii <eliz@gnu.org> writes: > Seems to work well, so could you please submit a full patch with the > commit log message, so we could then install this? > > Thanks. Sure. Attached. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1.2: [PATCH] ruler-mode: Improve compatibility with text-scale (bug#75168) --] [-- Type: text/x-patch, Size: 1813 bytes --] From 3e24ff3da4fd423f3d2b32679e87f2fc963482f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= <arsen@aarsen.me> Date: Sat, 18 Jan 2025 16:40:29 +0100 Subject: [PATCH] ruler-mode: Improve compatibility with text-scale (bug#75168) * lisp/ruler-mode.el (ruler-mode-ruler): Use pixelwise line-number display width for alignment with line numbers. --- lisp/ruler-mode.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el index 003dcae560f..64568e06cc9 100644 --- a/lisp/ruler-mode.el +++ b/lisp/ruler-mode.el @@ -632,12 +632,7 @@ ruler-mode-ruler (let* ((w (ruler-mode-text-scaled-window-width)) (m (window-margins)) (f (window-fringes)) - (i (if display-line-numbers - ;; FIXME: ruler-mode relies on I being an integer, so - ;; the column numbers might be slightly off if the - ;; line-number face is customized. - (round (line-number-display-width 'columns)) - 0)) + (i 0) (j (ruler-mode-text-scaled-window-hscroll)) ;; Setup the scrollbar, fringes, and margins areas. (lf (ruler-mode-space @@ -745,6 +740,12 @@ ruler-mode-ruler (dolist (p (nreverse props)) (add-text-properties (nth 0 p) (nth 1 p) (nthcdr 2 p) ruler-str)) + ;; Attach an alignment indent. + (if display-line-numbers + (setq ruler-str + (concat (ruler-mode-space `(,(line-number-display-width t))) + ruler-str))) + ;; Return the ruler propertized string. Using list here, ;; instead of concat visually separate the different areas. (if (nth 2 (window-fringes)) -- 2.48.0 [-- Attachment #1.3: Type: text/plain, Size: 45 bytes --] Have a lovely day. -- Arsen Arsenović [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 381 bytes --] ^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#75168: 31.0.50; text-scale confuses ruler-mode when display-line-number-mode is active 2025-01-18 15:45 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2025-01-18 15:54 ` Eli Zaretskii 0 siblings, 0 replies; 7+ messages in thread From: Eli Zaretskii @ 2025-01-18 15:54 UTC (permalink / raw) To: Arsen Arsenović; +Cc: 75168-done > From: Arsen Arsenović <arsen@aarsen.me> > Cc: 75168@debbugs.gnu.org > Date: Sat, 18 Jan 2025 16:45:53 +0100 > > Eli Zaretskii <eliz@gnu.org> writes: > > > Seems to work well, so could you please submit a full patch with the > > commit log message, so we could then install this? > > > > Thanks. > > Sure. Attached. Thanks, installed on master, and closing the bug. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-01-18 15:54 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-12-28 21:15 bug#75168: 31.0.50; text-scale confuses ruler-mode when display-line-number-mode is active Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-12-29 6:37 ` Eli Zaretskii 2024-12-29 12:06 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors 2025-01-11 13:16 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors 2025-01-18 9:58 ` Eli Zaretskii 2025-01-18 15:45 ` Arsen Arsenović via Bug reports for GNU Emacs, the Swiss army knife of text editors 2025-01-18 15:54 ` Eli Zaretskii
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.