mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
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:
parent
885c512603
commit
c3ac93bb9f
2 changed files with 18 additions and 3 deletions
|
|
@ -194,6 +194,8 @@ Populated by `tabulated-list-init-header'.")
|
||||||
mouse-face highlight
|
mouse-face highlight
|
||||||
keymap ,tabulated-list-sort-button-map))
|
keymap ,tabulated-list-sort-button-map))
|
||||||
(cols nil))
|
(cols nil))
|
||||||
|
(if display-line-numbers
|
||||||
|
(setq x (+ x (line-number-display-width) 2)))
|
||||||
(push (propertize " " 'display `(space :align-to ,x)) cols)
|
(push (propertize " " 'display `(space :align-to ,x)) cols)
|
||||||
(dotimes (n (length tabulated-list-format))
|
(dotimes (n (length tabulated-list-format))
|
||||||
(let* ((col (aref tabulated-list-format n))
|
(let* ((col (aref tabulated-list-format n))
|
||||||
|
|
@ -410,6 +412,8 @@ of column descriptors."
|
||||||
(x (max tabulated-list-padding 0))
|
(x (max tabulated-list-padding 0))
|
||||||
(ncols (length tabulated-list-format))
|
(ncols (length tabulated-list-format))
|
||||||
(inhibit-read-only t))
|
(inhibit-read-only t))
|
||||||
|
(if display-line-numbers
|
||||||
|
(setq x (+ x (line-number-display-width) 2)))
|
||||||
(if (> tabulated-list-padding 0)
|
(if (> tabulated-list-padding 0)
|
||||||
(insert (make-string x ?\s)))
|
(insert (make-string x ?\s)))
|
||||||
(let ((tabulated-list--near-rows ; Bind it if not bound yet (Bug#25506).
|
(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)
|
(defsubst ruler-mode-window-col (n)
|
||||||
"Return a column number relative to the selected window.
|
"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
|
(- n
|
||||||
(or (car (window-margins)) 0)
|
(or (car (window-margins)) 0)
|
||||||
(fringe-columns 'left)
|
(fringe-columns 'left)
|
||||||
|
|
@ -665,7 +668,7 @@ Optional argument PROPS specifies other text properties to apply."
|
||||||
(let* ((w (ruler-mode-text-scaled-window-width))
|
(let* ((w (ruler-mode-text-scaled-window-width))
|
||||||
(m (window-margins))
|
(m (window-margins))
|
||||||
(f (window-fringes))
|
(f (window-fringes))
|
||||||
(i 0)
|
(i (if display-line-numbers (+ (line-number-display-width) 2) 0))
|
||||||
(j (ruler-mode-text-scaled-window-hscroll))
|
(j (ruler-mode-text-scaled-window-hscroll))
|
||||||
;; Setup the scrollbar, fringes, and margins areas.
|
;; Setup the scrollbar, fringes, and margins areas.
|
||||||
(lf (ruler-mode-space
|
(lf (ruler-mode-space
|
||||||
|
|
@ -701,7 +704,15 @@ Optional argument PROPS specifies other text properties to apply."
|
||||||
;; hence the need for `string-to-multibyte'.
|
;; hence the need for `string-to-multibyte'.
|
||||||
;; http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00841.html
|
;; http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00841.html
|
||||||
(string-to-multibyte
|
(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
|
'face 'ruler-mode-default
|
||||||
'local-map ruler-mode-map
|
'local-map ruler-mode-map
|
||||||
'help-echo (cond
|
'help-echo (cond
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue