aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2017-10-05 17:57:58 +0300
committerEli Zaretskii2017-10-05 17:57:58 +0300
commitbd5326f879c089745c33871efc8682da5c206f80 (patch)
treed7abefd797507a1b890fb4d2104be563ed1e71b3
parent0c8f4e5ea122df9526037286e95844c64f3d964d (diff)
downloademacs-bd5326f879c089745c33871efc8682da5c206f80.tar.gz
emacs-bd5326f879c089745c33871efc8682da5c206f80.zip
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)
-rw-r--r--lisp/emacs-lisp/tabulated-list.el32
1 files changed, 13 insertions, 19 deletions
diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index 6c5874598ae..d1d7c0a8042 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -98,12 +98,9 @@ This is commonly used to recompute `tabulated-list-entries'.")
98 98
99(defvar-local tabulated-list-printer 'tabulated-list-print-entry 99(defvar-local tabulated-list-printer 'tabulated-list-print-entry
100 "Function for inserting a Tabulated List entry at point. 100 "Function for inserting a Tabulated List entry at point.
101It is called with two mandatory arguments, ID and COLS, and one 101It is called with two arguments, ID and COLS. ID is a Lisp
102optional argument, INDENT. ID is a Lisp object identifying the 102object identifying the entry, and COLS is a vector of column
103entry, and COLS is a vector of column 103descriptors, as documented in `tabulated-list-entries'.")
104descriptors, as documented in `tabulated-list-entries'.
105INDENT, if present, is the initial indentation of the entry in
106columns, it is used when `display-line-numbers' is in effect.")
107 104
108(defvar tabulated-list--near-rows) 105(defvar tabulated-list--near-rows)
109 106
@@ -332,6 +329,8 @@ Check the current row, the previous one and the next row."
332 (string-width (if (stringp nt) nt (car nt))))) 329 (string-width (if (stringp nt) nt (car nt)))))
333 tabulated-list--near-rows))) 330 tabulated-list--near-rows)))
334 331
332(defvar tabulated-list-entry-lnum-width nil)
333
335(defun tabulated-list-print (&optional remember-pos update) 334(defun tabulated-list-print (&optional remember-pos update)
336 "Populate the current Tabulated List mode buffer. 335 "Populate the current Tabulated List mode buffer.
337This sorts the `tabulated-list-entries' list if sorting is 336This sorts the `tabulated-list-entries' list if sorting is
@@ -353,7 +352,7 @@ changing `tabulated-list-sort-key'."
353 (funcall tabulated-list-entries) 352 (funcall tabulated-list-entries)
354 tabulated-list-entries)) 353 tabulated-list-entries))
355 (sorter (tabulated-list--get-sorter)) 354 (sorter (tabulated-list--get-sorter))
356 entry-id saved-pt saved-col window-line lnum-width) 355 entry-id saved-pt saved-col window-line)
357 (and remember-pos 356 (and remember-pos
358 (setq entry-id (tabulated-list-get-id)) 357 (setq entry-id (tabulated-list-get-id))
359 (setq saved-col (current-column)) 358 (setq saved-col (current-column))
@@ -374,7 +373,7 @@ changing `tabulated-list-sort-key'."
374 (unless tabulated-list-use-header-line 373 (unless tabulated-list-use-header-line
375 (tabulated-list-print-fake-header))) 374 (tabulated-list-print-fake-header)))
376 ;; Finally, print the resulting list. 375 ;; Finally, print the resulting list.
377 (setq lnum-width (tabulated-list-line-number-width)) 376 (setq tabulated-list-entry-lnum-width (tabulated-list-line-number-width))
378 (while entries 377 (while entries
379 (let* ((elt (car entries)) 378 (let* ((elt (car entries))
380 (tabulated-list--near-rows 379 (tabulated-list--near-rows
@@ -389,7 +388,7 @@ changing `tabulated-list-sort-key'."
389 saved-pt (point))) 388 saved-pt (point)))
390 ;; If the buffer is empty, simply print each elt. 389 ;; If the buffer is empty, simply print each elt.
391 (if (or (not update) (eobp)) 390 (if (or (not update) (eobp))
392 (apply tabulated-list-printer (append elt (list lnum-width))) 391 (apply tabulated-list-printer elt)
393 (while (let ((local-id (tabulated-list-get-id))) 392 (while (let ((local-id (tabulated-list-get-id)))
394 ;; If we find id, then nothing to update. 393 ;; If we find id, then nothing to update.
395 (cond ((equal id local-id) 394 (cond ((equal id local-id)
@@ -402,8 +401,7 @@ changing `tabulated-list-sort-key'."
402 ;; FIXME: Might be faster if 401 ;; FIXME: Might be faster if
403 ;; don't construct this list. 402 ;; don't construct this list.
404 (list local-id (tabulated-list-get-entry)))) 403 (list local-id (tabulated-list-get-entry))))
405 (apply tabulated-list-printer 404 (apply tabulated-list-printer elt)
406 (append elt (list lnum-width)))
407 nil) 405 nil)
408 ;; We find an entry that sorts before id, 406 ;; We find an entry that sorts before id,
409 ;; it needs to be deleted. 407 ;; it needs to be deleted.
@@ -421,22 +419,18 @@ changing `tabulated-list-sort-key'."
421 (recenter window-line))) 419 (recenter window-line)))
422 (goto-char (point-min))))) 420 (goto-char (point-min)))))
423 421
424(defun tabulated-list-print-entry (id cols &optional indent) 422(defun tabulated-list-print-entry (id cols)
425 "Insert a Tabulated List entry at point. 423 "Insert a Tabulated List entry at point.
426This is the default `tabulated-list-printer' function. ID is a 424This is the default `tabulated-list-printer' function. ID is a
427Lisp object identifying the entry to print, and COLS is a vector 425Lisp object identifying the entry to print, and COLS is a vector
428of column descriptors. 426of column descriptors."
429Optional argument INDENT is the initial indent of the entry, in
430columns. This is used when `display-line-numbers' is in effect.
431If INDENT is omitted or nil, it is treated as zero."
432 (let ((beg (point)) 427 (let ((beg (point))
433 (x (max tabulated-list-padding 0)) 428 (x (max tabulated-list-padding 0))
434 (ncols (length tabulated-list-format)) 429 (ncols (length tabulated-list-format))
435 (inhibit-read-only t)) 430 (inhibit-read-only t))
436 (or indent (setq indent 0)) 431 (setq x (+ x tabulated-list-entry-lnum-width))
437 (setq x (+ x indent))
438 (if (> tabulated-list-padding 0) 432 (if (> tabulated-list-padding 0)
439 (insert (make-string (- x indent) ?\s))) 433 (insert (make-string (- x tabulated-list-entry-lnum-width) ?\s)))
440 (let ((tabulated-list--near-rows ; Bind it if not bound yet (Bug#25506). 434 (let ((tabulated-list--near-rows ; Bind it if not bound yet (Bug#25506).
441 (or (bound-and-true-p tabulated-list--near-rows) 435 (or (bound-and-true-p tabulated-list--near-rows)
442 (list (or (tabulated-list-get-entry (point-at-bol 0)) 436 (list (or (tabulated-list-get-entry (point-at-bol 0))