Function: tabulated-list-print
tabulated-list-print is a byte-compiled function defined in
tabulated-list.el.gz.
Signature
(tabulated-list-print &optional REMEMBER-POS UPDATE)
Documentation
Populate the current Tabulated List mode buffer.
This sorts the tabulated-list-entries list if sorting is
specified by tabulated-list-sort-key. It then erases the
buffer and inserts the entries with tabulated-list-printer.
If tabulated-list-groups(var)/tabulated-list-groups(fun) is non-nil, each group of entries
is printed and sorted separately.
Optional argument REMEMBER-POS, if non-nil, means to move point to the entry with the same ID element as the current line.
Non-nil UPDATE argument means to use an alternative printing
method which is faster if most entries haven't changed since the
last print. The only difference in outcome is that tags will not
be removed from entries that haven't changed (see
tabulated-list-put-tag). Don't use this immediately after
changing tabulated-list-sort-key.
Probably introduced at or before Emacs version 25.1.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/tabulated-list.el.gz
(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
specified by `tabulated-list-sort-key'. It then erases the
buffer and inserts the entries with `tabulated-list-printer'.
If `tabulated-list-groups' is non-nil, each group of entries
is printed and sorted separately.
Optional argument REMEMBER-POS, if non-nil, means to move point
to the entry with the same ID element as the current line.
Non-nil UPDATE argument means to use an alternative printing
method which is faster if most entries haven't changed since the
last print. The only difference in outcome is that tags will not
be removed from entries that haven't changed (see
`tabulated-list-put-tag'). Don't use this immediately after
changing `tabulated-list-sort-key'."
(let ((inhibit-read-only t)
(groups (if (functionp tabulated-list-groups)
(funcall tabulated-list-groups)
tabulated-list-groups))
(entries (if (functionp tabulated-list-entries)
(funcall tabulated-list-entries)
tabulated-list-entries))
(sorter (tabulated-list--get-sorter))
entry-id saved-pt saved-col)
(and remember-pos
(setq entry-id (tabulated-list-get-id))
(setq saved-col (current-column)))
;; Sort the entries, if necessary.
(when sorter
(if groups
(setq groups
(mapcar (lambda (group)
(cons (car group) (sort (cdr group) sorter)))
groups))
(setq entries (sort entries sorter))))
(unless (functionp tabulated-list-groups)
(setq tabulated-list-groups groups))
(unless (functionp tabulated-list-entries)
(setq tabulated-list-entries entries))
;; Without a sorter, we have no way to just update.
(when (and update (not sorter))
(setq update nil))
(if update (goto-char (point-min))
;; Redo the buffer, unless we're just updating.
(erase-buffer)
(unless tabulated-list-use-header-line
(tabulated-list-print-fake-header)))
;; Finally, print the resulting list.
(if groups
(dolist (group groups)
(insert (car group) ?\n)
(when-let ((saved-pt-new (tabulated-list-print-entries
(cdr group) sorter update entry-id)))
(setq saved-pt saved-pt-new)))
(setq saved-pt (tabulated-list-print-entries
entries sorter update entry-id)))
(when update
(delete-region (point) (point-max)))
(set-buffer-modified-p nil)
;; If REMEMBER-POS was specified, move to the "old" location.
(if saved-pt
(progn (goto-char saved-pt)
(move-to-column saved-col))
(goto-char (point-min)))))