Make header line in some modes be sensitive to display-line-numbers

* lisp/ruler-mode.el (ruler-mode-ruler, ruler-mode-window-col):
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-init-header)
(tabulated-list-print-entry): Account for the width taken by
line-number display.  (Bug#27895)
This commit is contained in:
Eli Zaretskii 2017-08-05 14:22:04 +03:00
parent 885c512603
commit c3ac93bb9f
2 changed files with 18 additions and 3 deletions

View file

@ -304,7 +304,10 @@ or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or
(defsubst ruler-mode-window-col (n)
"Return a column number relative to the selected window.
N is a column number relative to selected frame."
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)))
(- n
(or (car (window-margins)) 0)
(fringe-columns 'left)
@ -665,7 +668,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 0)
(i (if display-line-numbers (+ (line-number-display-width) 2) 0))
(j (ruler-mode-text-scaled-window-hscroll))
;; Setup the scrollbar, fringes, and margins areas.
(lf (ruler-mode-space
@ -701,7 +704,15 @@ Optional argument PROPS specifies other text properties to apply."
;; hence the need for `string-to-multibyte'.
;; http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00841.html
(string-to-multibyte
(make-string w ruler-mode-basic-graduation-char))
;; Make the part of header-line corresponding to the
;; line-number display be blank, not filled with
;; ruler-mode-basic-graduation-char.
(if display-line-numbers
(let* ((lndw (+ (line-number-display-width) 2))
(s (make-string lndw ?\s)))
(concat s (make-string (- w lndw)
ruler-mode-basic-graduation-char)))
(make-string w ruler-mode-basic-graduation-char)))
'face 'ruler-mode-default
'local-map ruler-mode-map
'help-echo (cond