I want to print an alist with a title consisting of a key title keytl
and a value title valtl
before printing the values using tabulated-list-print
.
(defun tlprint-alist (alist &optional outbufr keytl valtl)
"Print an associated list via `tabulated-list-print'."
(let*
( (bufr (or outbufr (get-buffer-create "*Alist*")))
(keytl (or keytl "Key Title"))
(valtl (or valtl "Value Title")) )
(with-current-buffer bufr
(setq tabulated-list-format [(keytl 20 t) (valtl 20 t)])
(setq tabulated-list-sort-key (cons keytl nil))
(setq tabulated-list-entries
(cons (list keytl valtl)
(mapcar (lambda (pair)
(list (car pair) (cdr pair)))
alist)))
(tabulated-list-print) )))
Running
(setq foo '((a . ["a1" "a2"]) (b . ["b1" "b2"]) (c . ["c1" "c2"])))
(tlprint-alist foo)
gives
Debugger entered--Lisp error: (error "No column named Key Title")
signal(error ("No column named Key Title"))
error("No column named %s" "Key Title")
tabulated-list--column-number("Key Title")
tabulated-list--get-sorter()
tabulated-list-print()