unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Printing a header with tabulated-list-mode
@ 2023-06-15 12:03 Heime
  2023-06-24 19:03 ` Jean Louis
  2023-06-24 19:05 ` Jean Louis
  0 siblings, 2 replies; 3+ messages in thread
From: Heime @ 2023-06-15 12:03 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor


I want to print an alist with a header using tabulated-list-print

(setq foo '((a . ["a1" "a2"]) (b . ["bb1" "bb2"]) (c . ["ccc1" "ccc2"])))
(tlprint-alist foo)

But the header is not being displayed.

(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
      (tabulated-list-mode)
      (setq tabulated-list-format
             (vector (list keytl 20 t) (list valtl 20 t)))
      (setq tabulated-list-sort-key (cons keytl nil))
      (setq tabulated-list-entries
            (mapcar (lambda (pair)
                      (list (car pair) (cdr pair)))
                    alist))
      (tabulated-list-init-header)
      (tabulated-list-print) )))






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-24 19:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-15 12:03 Printing a header with tabulated-list-mode Heime
2023-06-24 19:03 ` Jean Louis
2023-06-24 19:05 ` Jean Louis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).