help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Printing a header with tabulated-list-mode


From: Heime
Subject: Printing a header with tabulated-list-mode
Date: Thu, 15 Jun 2023 12:03:17 +0000

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) )))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]