mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08: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:
parent
0c8f4e5ea1
commit
bd5326f879
1 changed files with 13 additions and 19 deletions
|
|
@ -98,12 +98,9 @@ This is commonly used to recompute `tabulated-list-entries'.")
|
||||||
|
|
||||||
(defvar-local tabulated-list-printer 'tabulated-list-print-entry
|
(defvar-local tabulated-list-printer 'tabulated-list-print-entry
|
||||||
"Function for inserting a Tabulated List entry at point.
|
"Function for inserting a Tabulated List entry at point.
|
||||||
It is called with two mandatory arguments, ID and COLS, and one
|
It is called with two arguments, ID and COLS. ID is a Lisp
|
||||||
optional argument, INDENT. ID is a Lisp object identifying the
|
object identifying the entry, and COLS is a vector of column
|
||||||
entry, and COLS is a vector of column
|
descriptors, as documented in `tabulated-list-entries'.")
|
||||||
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.")
|
|
||||||
|
|
||||||
(defvar tabulated-list--near-rows)
|
(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)))))
|
(string-width (if (stringp nt) nt (car nt)))))
|
||||||
tabulated-list--near-rows)))
|
tabulated-list--near-rows)))
|
||||||
|
|
||||||
|
(defvar tabulated-list-entry-lnum-width nil)
|
||||||
|
|
||||||
(defun tabulated-list-print (&optional remember-pos update)
|
(defun tabulated-list-print (&optional remember-pos update)
|
||||||
"Populate the current Tabulated List mode buffer.
|
"Populate the current Tabulated List mode buffer.
|
||||||
This sorts the `tabulated-list-entries' list if sorting is
|
This sorts the `tabulated-list-entries' list if sorting is
|
||||||
|
|
@ -353,7 +352,7 @@ changing `tabulated-list-sort-key'."
|
||||||
(funcall tabulated-list-entries)
|
(funcall tabulated-list-entries)
|
||||||
tabulated-list-entries))
|
tabulated-list-entries))
|
||||||
(sorter (tabulated-list--get-sorter))
|
(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
|
(and remember-pos
|
||||||
(setq entry-id (tabulated-list-get-id))
|
(setq entry-id (tabulated-list-get-id))
|
||||||
(setq saved-col (current-column))
|
(setq saved-col (current-column))
|
||||||
|
|
@ -374,7 +373,7 @@ changing `tabulated-list-sort-key'."
|
||||||
(unless tabulated-list-use-header-line
|
(unless tabulated-list-use-header-line
|
||||||
(tabulated-list-print-fake-header)))
|
(tabulated-list-print-fake-header)))
|
||||||
;; Finally, print the resulting list.
|
;; 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
|
(while entries
|
||||||
(let* ((elt (car entries))
|
(let* ((elt (car entries))
|
||||||
(tabulated-list--near-rows
|
(tabulated-list--near-rows
|
||||||
|
|
@ -389,7 +388,7 @@ changing `tabulated-list-sort-key'."
|
||||||
saved-pt (point)))
|
saved-pt (point)))
|
||||||
;; If the buffer is empty, simply print each elt.
|
;; If the buffer is empty, simply print each elt.
|
||||||
(if (or (not update) (eobp))
|
(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)))
|
(while (let ((local-id (tabulated-list-get-id)))
|
||||||
;; If we find id, then nothing to update.
|
;; If we find id, then nothing to update.
|
||||||
(cond ((equal id local-id)
|
(cond ((equal id local-id)
|
||||||
|
|
@ -402,8 +401,7 @@ changing `tabulated-list-sort-key'."
|
||||||
;; FIXME: Might be faster if
|
;; FIXME: Might be faster if
|
||||||
;; don't construct this list.
|
;; don't construct this list.
|
||||||
(list local-id (tabulated-list-get-entry))))
|
(list local-id (tabulated-list-get-entry))))
|
||||||
(apply tabulated-list-printer
|
(apply tabulated-list-printer elt)
|
||||||
(append elt (list lnum-width)))
|
|
||||||
nil)
|
nil)
|
||||||
;; We find an entry that sorts before id,
|
;; We find an entry that sorts before id,
|
||||||
;; it needs to be deleted.
|
;; it needs to be deleted.
|
||||||
|
|
@ -421,22 +419,18 @@ changing `tabulated-list-sort-key'."
|
||||||
(recenter window-line)))
|
(recenter window-line)))
|
||||||
(goto-char (point-min)))))
|
(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.
|
"Insert a Tabulated List entry at point.
|
||||||
This is the default `tabulated-list-printer' function. ID is a
|
This is the default `tabulated-list-printer' function. ID is a
|
||||||
Lisp object identifying the entry to print, and COLS is a vector
|
Lisp object identifying the entry to print, and COLS is a vector
|
||||||
of column descriptors.
|
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."
|
|
||||||
(let ((beg (point))
|
(let ((beg (point))
|
||||||
(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))
|
||||||
(or indent (setq indent 0))
|
(setq x (+ x tabulated-list-entry-lnum-width))
|
||||||
(setq x (+ x indent))
|
|
||||||
(if (> tabulated-list-padding 0)
|
(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).
|
(let ((tabulated-list--near-rows ; Bind it if not bound yet (Bug#25506).
|
||||||
(or (bound-and-true-p tabulated-list--near-rows)
|
(or (bound-and-true-p tabulated-list--near-rows)
|
||||||
(list (or (tabulated-list-get-entry (point-at-bol 0))
|
(list (or (tabulated-list-get-entry (point-at-bol 0))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue