Commit c3ac93bb authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

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)
parent 885c5126
......@@ -194,6 +194,8 @@ Populated by `tabulated-list-init-header'.")
mouse-face highlight
keymap ,tabulated-list-sort-button-map))
(cols nil))
(if display-line-numbers
(setq x (+ x (line-number-display-width) 2)))
(push (propertize " " 'display `(space :align-to ,x)) cols)
(dotimes (n (length tabulated-list-format))
(let* ((col (aref tabulated-list-format n))
......@@ -410,6 +412,8 @@ of column descriptors."
(x (max tabulated-list-padding 0))
(ncols (length tabulated-list-format))
(inhibit-read-only t))
(if display-line-numbers
(setq x (+ x (line-number-display-width) 2)))
(if (> tabulated-list-padding 0)
(insert (make-string x ?\s)))
(let ((tabulated-list--near-rows ; Bind it if not bound yet (Bug#25506).
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment