]> git.eshelyaron.com Git - emacs.git/commitdiff
ruler-mode: Improve compatibility with text-scale (bug#75168)
authorArsen Arsenović <arsen@aarsen.me>
Sat, 18 Jan 2025 15:40:29 +0000 (16:40 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sat, 18 Jan 2025 22:05:09 +0000 (23:05 +0100)
* lisp/ruler-mode.el (ruler-mode-ruler): Use pixelwise line-number
display width for alignment with line numbers.

(cherry picked from commit 311b3f70f543a106bc9ebc369b69432a106b0e38)

lisp/ruler-mode.el

index 003dcae560f7b38f5296ff87a229fb997f4311cd..64568e06cc9058a7974efdc9fd645351e5f6157a 100644 (file)
@@ -632,12 +632,7 @@ Optional argument PROPS specifies other text properties to apply."
   (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 @@ Optional argument PROPS specifies other text properties to apply."
       (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))