Function: vtable--insert
vtable--insert is a byte-compiled function defined in vtable.el.gz.
Signature
(vtable--insert TABLE)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/vtable.el.gz
(defun vtable--insert (table)
(let* ((spacer (vtable--spacer table))
(start (point))
(ellipsis (if (vtable-ellipsis table)
(propertize (truncate-string-ellipsis)
'face (vtable-face table))
""))
(ellipsis-width (string-pixel-width ellipsis (vtable-buffer table)))
;; We maintain a cache per screen/window width, so that we render
;; correctly if Emacs is open on two different screens (or the
;; user resizes the frame).
(cache (or (gethash (vtable--cache-key) (slot-value table '-cache))
(let* ((data (vtable--compute-cache table))
(widths (vtable--compute-widths table data)))
(setf (gethash (vtable--cache-key) (slot-value table '-cache))
(list data widths)))))
(widths (vtable--cache-widths cache)))
;; Don't insert any header or header line if the user hasn't
;; specified the columns.
(when (slot-value table '-has-column-spec)
(if (vtable-use-header-line table)
(vtable--set-header-line table widths spacer)
;; Insert the header line directly into the buffer, and put a
;; keymap to be able to sort the columns there (by clicking on
;; them).
(vtable--insert-header-line table widths spacer)
(add-text-properties start (point)
(list 'keymap vtable-header-line-map
'rear-nonsticky t
'vtable table))
(setq start (point))))
(vtable--sort table cache)
;; Insert the data.
(let ((line-number 0))
(dolist (line (vtable--cache-lines cache))
(vtable--insert-line table line line-number widths spacer
ellipsis ellipsis-width)
(setq line-number (1+ line-number))))
(add-text-properties start (point)
(list 'rear-nonsticky t
'vtable table))
(setf (vtable--current-cache table) cache)
(goto-char start)))