1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-18 18:05:07 +00:00

Fix breakage due to recent change in tabulated-list-print-entry

* lisp/emacs-lisp/tabulated-list.el (tabulated-list-printer):
Update the doc string.
(tabulated-list-print-entry): Revert to using only 2 arguments.
Update the doc string.
(tabulated-list-entry-lnum-width): New defvar.
(tabulated-list-print): Compute the width of line-number display
once, then store that value in tabulated-list-entry-lnum-width,
for tabulated-list-printer to use.  (Bug#28704)
This commit is contained in:
Eli Zaretskii 2017-10-05 17:57:58 +03:00
parent 0c8f4e5ea1
commit bd5326f879

View File

@ -98,12 +98,9 @@ This is commonly used to recompute `tabulated-list-entries'.")
(defvar-local tabulated-list-printer 'tabulated-list-print-entry
"Function for inserting a Tabulated List entry at point.
It is called with two mandatory arguments, ID and COLS, and one
optional argument, INDENT. ID is a Lisp object identifying the
entry, and COLS is a vector of column
descriptors, as documented in `tabulated-list-entries'.
INDENT, if present, is the initial indentation of the entry in
columns, it is used when `display-line-numbers' is in effect.")
It is called with two arguments, ID and COLS. ID is a Lisp
object identifying the entry, and COLS is a vector of column
descriptors, as documented in `tabulated-list-entries'.")
(defvar tabulated-list--near-rows)
@ -332,6 +329,8 @@ Check the current row, the previous one and the next row."
(string-width (if (stringp nt) nt (car nt)))))
tabulated-list--near-rows)))
(defvar tabulated-list-entry-lnum-width nil)
(defun tabulated-list-print (&optional remember-pos update)
"Populate the current Tabulated List mode buffer.
This sorts the `tabulated-list-entries' list if sorting is
@ -353,7 +352,7 @@ changing `tabulated-list-sort-key'."
(funcall tabulated-list-entries)
tabulated-list-entries))
(sorter (tabulated-list--get-sorter))
entry-id saved-pt saved-col window-line lnum-width)
entry-id saved-pt saved-col window-line)
(and remember-pos
(setq entry-id (tabulated-list-get-id))
(setq saved-col (current-column))
@ -374,7 +373,7 @@ changing `tabulated-list-sort-key'."
(unless tabulated-list-use-header-line
(tabulated-list-print-fake-header)))
;; Finally, print the resulting list.
(setq lnum-width (tabulated-list-line-number-width))
(setq tabulated-list-entry-lnum-width (tabulated-list-line-number-width))
(while entries
(let* ((elt (car entries))
(tabulated-list--near-rows
@ -389,7 +388,7 @@ changing `tabulated-list-sort-key'."
saved-pt (point)))
;; If the buffer is empty, simply print each elt.
(if (or (not update) (eobp))
(apply tabulated-list-printer (append elt (list lnum-width)))
(apply tabulated-list-printer elt)
(while (let ((local-id (tabulated-list-get-id)))
;; If we find id, then nothing to update.
(cond ((equal id local-id)
@ -402,8 +401,7 @@ changing `tabulated-list-sort-key'."
;; FIXME: Might be faster if
;; don't construct this list.
(list local-id (tabulated-list-get-entry))))
(apply tabulated-list-printer
(append elt (list lnum-width)))
(apply tabulated-list-printer elt)
nil)
;; We find an entry that sorts before id,
;; it needs to be deleted.
@ -421,22 +419,18 @@ changing `tabulated-list-sort-key'."
(recenter window-line)))
(goto-char (point-min)))))
(defun tabulated-list-print-entry (id cols &optional indent)
(defun tabulated-list-print-entry (id cols)
"Insert a Tabulated List entry at point.
This is the default `tabulated-list-printer' function. ID is a
Lisp object identifying the entry to print, and COLS is a vector
of column descriptors.
Optional argument INDENT is the initial indent of the entry, in
columns. This is used when `display-line-numbers' is in effect.
If INDENT is omitted or nil, it is treated as zero."
of column descriptors."
(let ((beg (point))
(x (max tabulated-list-padding 0))
(ncols (length tabulated-list-format))
(inhibit-read-only t))
(or indent (setq indent 0))
(setq x (+ x indent))
(setq x (+ x tabulated-list-entry-lnum-width))
(if (> tabulated-list-padding 0)
(insert (make-string (- x indent) ?\s)))
(insert (make-string (- x tabulated-list-entry-lnum-width) ?\s)))
(let ((tabulated-list--near-rows ; Bind it if not bound yet (Bug#25506).
(or (bound-and-true-p tabulated-list--near-rows)
(list (or (tabulated-list-get-entry (point-at-bol 0))