Function: tabulated-list-print-col
tabulated-list-print-col is a byte-compiled function defined in
tabulated-list.el.gz.
Signature
(tabulated-list-print-col N COL-DESC X)
Documentation
Insert a specified Tabulated List entry at point.
N is the column number, COL-DESC is a column descriptor (see
tabulated-list-entries), and X is the column number at point.
Return the column number after insertion.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/tabulated-list.el.gz
(defun tabulated-list-print-col (n col-desc x)
"Insert a specified Tabulated List entry at point.
N is the column number, COL-DESC is a column descriptor (see
`tabulated-list-entries'), and X is the column number at point.
Return the column number after insertion."
(let* ((format (aref tabulated-list-format n))
(name (nth 0 format))
(width (nth 1 format))
(props (nthcdr 3 format))
(pad-right (or (plist-get props :pad-right) 1))
(right-align (plist-get props :right-align))
(label (cond ((stringp col-desc) col-desc)
((eq (car col-desc) 'image) " ")
(t (car col-desc))))
(label-width (string-width label))
(help-echo (concat (car format) ": " label))
(opoint (point))
(not-last-col (< (1+ n) (length tabulated-list-format)))
(available-space (and not-last-col
(if right-align
width
(tabulated-list--available-space width n)))))
;; Truncate labels if necessary (except last column).
;; Don't truncate to `width' if the next column is align-right
;; and has some space left, truncate to `available-space' instead.
(when (and not-last-col
(> label-width available-space))
(setq label (truncate-string-to-width
label available-space nil nil t t)
label-width available-space))
(setq label (bidi-string-mark-left-to-right label))
(when (and right-align (> width label-width))
(let ((shift (- width label-width)))
(insert (propertize (make-string shift ?\s)
'display `(space :align-to ,(+ x shift))))
(setq width (- width shift))
(setq x (+ x shift))))
(cond ((stringp col-desc)
(insert (if (get-text-property 0 'help-echo label)
label
(propertize label 'help-echo help-echo))))
((eq (car col-desc) 'image)
(insert (propertize " "
'display col-desc
'help-echo help-echo)))
((apply 'insert-text-button label (cdr col-desc))))
(let ((next-x (+ x pad-right width)))
;; No need to append any spaces if this is the last column.
(when not-last-col
(when (> pad-right 0) (insert (make-string pad-right ?\s)))
(insert (propertize
(make-string (- width (min width label-width)) ?\s)
'display `(space :align-to ,next-x))))
(put-text-property opoint (point) 'tabulated-list-column-name name)
next-x)))