diff options
author | Eli Zaretskii <eliz@gnu.org> | 2017-08-05 14:22:04 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2017-08-05 14:22:04 +0300 |
commit | c3ac93bb9ff8b1fe1fc32f99c725e6cc209aa6ca (patch) | |
tree | cf2bb687be96accf6fb3b0c8e40fef7e00807264 /lisp/ruler-mode.el | |
parent | 885c512603f946dfb7a45c181e94b8677be2678d (diff) | |
download | emacs-c3ac93bb9ff8b1fe1fc32f99c725e6cc209aa6ca.tar.gz |
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)
Diffstat (limited to 'lisp/ruler-mode.el')
-rw-r--r-- | lisp/ruler-mode.el | 17 |
1 files changed, 14 insertions, 3 deletions
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 (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 |