Populated by `tabulated-list-init-header'.")
(defvar tabulated-list--header-overlay nil)
+(defun tabulated-list-line-number-width ()
+ "Return the width taken by display-line-numbers in the current buffer."
+ ;; line-number-display-width returns the value for the selected
+ ;; window, which might not be the window in which the current buffer
+ ;; is displayed.
+ (let ((cbuf-window (get-buffer-window (current-buffer))))
+ (if (window-live-p cbuf-window)
+ (with-selected-window cbuf-window
+ (+ (line-number-display-width) 2))
+ 4)))
+
(defun tabulated-list-init-header ()
"Set up header line for the Tabulated List buffer."
;; FIXME: Should share code with tabulated-list-print-col!
keymap ,tabulated-list-sort-button-map))
(cols nil))
(if display-line-numbers
- (setq x (+ x (line-number-display-width) 2)))
+ (setq x (+ x (tabulated-list-line-number-width))))
(push (propertize " " 'display `(space :align-to ,x)) cols)
(dotimes (n (length tabulated-list-format))
(let* ((col (aref tabulated-list-format n))
(ncols (length tabulated-list-format))
(inhibit-read-only t))
(if display-line-numbers
- (setq x (+ x (line-number-display-width) 2)))
+ (setq x (+ x (tabulated-list-line-number-width))))
(if (> tabulated-list-padding 0)
(insert (make-string x ?\s)))
(let ((tabulated-list--near-rows ; Bind it if not bound yet (Bug#25506).