summaryrefslogtreecommitdiff
path: root/lisp/ruler-mode.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/ruler-mode.el')
-rw-r--r--lisp/ruler-mode.el16
1 files changed, 13 insertions, 3 deletions
diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el
index 7a23f4d03c0..3d27858d0fe 100644
--- a/lisp/ruler-mode.el
+++ b/lisp/ruler-mode.el
@@ -307,7 +307,12 @@ or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or
N is a column number relative to selected frame.
If required, account for screen estate taken by `display-line-numbers'."
(if display-line-numbers
- (setq n (- n (line-number-display-width) 2)))
+ ;; FIXME: ruler-mode relies on N being an integer, so if the
+ ;; 'line-number' face is customized to use a font that is larger
+ ;; or smaller than that of the default face, the alignment might
+ ;; be off by up to half a column, unless the font width is an
+ ;; integral multiple or divisor of the default face's font.
+ (setq n (- n (round (line-number-display-width 'columns)))))
(- n
(or (car (window-margins)) 0)
(fringe-columns 'left)
@@ -668,7 +673,12 @@ 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 (+ (line-number-display-width) 2) 0))
+ (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))
(j (ruler-mode-text-scaled-window-hscroll))
;; Setup the scrollbar, fringes, and margins areas.
(lf (ruler-mode-space
@@ -708,7 +718,7 @@ Optional argument PROPS specifies other text properties to apply."
;; line-number display be blank, not filled with
;; ruler-mode-basic-graduation-char.
(if display-line-numbers
- (let* ((lndw (+ (line-number-display-width) 2))
+ (let* ((lndw (round (line-number-display-width 'columns)))
(s (make-string lndw ?\s)))
(concat s (make-string (- w lndw)
ruler-mode-basic-graduation-char)))