aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2017-08-05 14:22:04 +0300
committerEli Zaretskii2017-08-05 14:22:04 +0300
commitc3ac93bb9ff8b1fe1fc32f99c725e6cc209aa6ca (patch)
treecf2bb687be96accf6fb3b0c8e40fef7e00807264
parent885c512603f946dfb7a45c181e94b8677be2678d (diff)
downloademacs-c3ac93bb9ff8b1fe1fc32f99c725e6cc209aa6ca.tar.gz
emacs-c3ac93bb9ff8b1fe1fc32f99c725e6cc209aa6ca.zip
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)
-rw-r--r--lisp/emacs-lisp/tabulated-list.el4
-rw-r--r--lisp/ruler-mode.el17
2 files changed, 18 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index b6b49b1bfa2..8ff5cdf18e8 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -194,6 +194,8 @@ Populated by `tabulated-list-init-header'.")
194 mouse-face highlight 194 mouse-face highlight
195 keymap ,tabulated-list-sort-button-map)) 195 keymap ,tabulated-list-sort-button-map))
196 (cols nil)) 196 (cols nil))
197 (if display-line-numbers
198 (setq x (+ x (line-number-display-width) 2)))
197 (push (propertize " " 'display `(space :align-to ,x)) cols) 199 (push (propertize " " 'display `(space :align-to ,x)) cols)
198 (dotimes (n (length tabulated-list-format)) 200 (dotimes (n (length tabulated-list-format))
199 (let* ((col (aref tabulated-list-format n)) 201 (let* ((col (aref tabulated-list-format n))
@@ -410,6 +412,8 @@ of column descriptors."
410 (x (max tabulated-list-padding 0)) 412 (x (max tabulated-list-padding 0))
411 (ncols (length tabulated-list-format)) 413 (ncols (length tabulated-list-format))
412 (inhibit-read-only t)) 414 (inhibit-read-only t))
415 (if display-line-numbers
416 (setq x (+ x (line-number-display-width) 2)))
413 (if (> tabulated-list-padding 0) 417 (if (> tabulated-list-padding 0)
414 (insert (make-string x ?\s))) 418 (insert (make-string x ?\s)))
415 (let ((tabulated-list--near-rows ; Bind it if not bound yet (Bug#25506). 419 (let ((tabulated-list--near-rows ; Bind it if not bound yet (Bug#25506).
diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el
index fdfd5c61be9..16277973d60 100644
--- a/lisp/ruler-mode.el
+++ b/lisp/ruler-mode.el
@@ -304,7 +304,10 @@ or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or
304 304
305(defsubst ruler-mode-window-col (n) 305(defsubst ruler-mode-window-col (n)
306 "Return a column number relative to the selected window. 306 "Return a column number relative to the selected window.
307N is a column number relative to selected frame." 307N is a column number relative to selected frame.
308If required, account for screen estate taken by `display-line-numbers'."
309 (if display-line-numbers
310 (setq n (- n (line-number-display-width) 2)))
308 (- n 311 (- n
309 (or (car (window-margins)) 0) 312 (or (car (window-margins)) 0)
310 (fringe-columns 'left) 313 (fringe-columns 'left)
@@ -665,7 +668,7 @@ Optional argument PROPS specifies other text properties to apply."
665 (let* ((w (ruler-mode-text-scaled-window-width)) 668 (let* ((w (ruler-mode-text-scaled-window-width))
666 (m (window-margins)) 669 (m (window-margins))
667 (f (window-fringes)) 670 (f (window-fringes))
668 (i 0) 671 (i (if display-line-numbers (+ (line-number-display-width) 2) 0))
669 (j (ruler-mode-text-scaled-window-hscroll)) 672 (j (ruler-mode-text-scaled-window-hscroll))
670 ;; Setup the scrollbar, fringes, and margins areas. 673 ;; Setup the scrollbar, fringes, and margins areas.
671 (lf (ruler-mode-space 674 (lf (ruler-mode-space
@@ -701,7 +704,15 @@ Optional argument PROPS specifies other text properties to apply."
701 ;; hence the need for `string-to-multibyte'. 704 ;; hence the need for `string-to-multibyte'.
702 ;; http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00841.html 705 ;; http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00841.html
703 (string-to-multibyte 706 (string-to-multibyte
704 (make-string w ruler-mode-basic-graduation-char)) 707 ;; Make the part of header-line corresponding to the
708 ;; line-number display be blank, not filled with
709 ;; ruler-mode-basic-graduation-char.
710 (if display-line-numbers
711 (let* ((lndw (+ (line-number-display-width) 2))
712 (s (make-string lndw ?\s)))
713 (concat s (make-string (- w lndw)
714 ruler-mode-basic-graduation-char)))
715 (make-string w ruler-mode-basic-graduation-char)))
705 'face 'ruler-mode-default 716 'face 'ruler-mode-default
706 'local-map ruler-mode-map 717 'local-map ruler-mode-map
707 'help-echo (cond 718 'help-echo (cond