* 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
* Re: Printing a header with tabulated-list-mode
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
1 sibling, 0 replies; 3+ messages in thread
From: Jean Louis @ 2023-06-24 19:03 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
* Heime <heimeborgia@protonmail.com> [2023-06-15 13:21]:
>
> 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) )))
This is my main function using tabulated-list-mode, if you can get anything from it:
(defun rcd-db-report (title entries format database-type db-handle table sort-key
&optional refresh highlight-list place id return-function)
"RCD database report.
TITLE is buffer name."
(setq rcd-db-current-database-type database-type)
(let* ((buffer (generate-new-buffer-name (rcd-notes-name title))))
(let* ((buffer (get-buffer-create buffer))
(mode-map (rcd-db-table-mode-map table)))
(cond ((string-equal table "edit") (switch-to-buffer buffer))
(rcd-dont-switch-windows (switch-to-buffer buffer))
(t (switch-to-buffer-other-window buffer)))
(setq tabulated-list-format format)
(setq tabulated-list-entries entries)
(setq rcd-db-edited-table table)
(setq rcd-db-current-database-type database-type)
(setq rcd-tabulated-refresh-function refresh)
(setq rcd-current-return-function return-function)
(rcd-db-list-mode)
(use-local-map mode-map)
(setq rcd-tabulated-marked-items nil)
(setq rcd-db-current-database-handle db-handle)
(setq rcd-db-current-table (or (alist-get "table" place nil nil 'equal) table))
(setq rcd-db-current-table-id id)
(setq tabulated-list-padding 1)
(tabulated-list-init-header))
(setq tabulated-list-sort-key sort-key)
(tabulated-list-print t)
(when highlight-list
(rcd-highlight-list highlight-list))))
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Printing a header with tabulated-list-mode
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
1 sibling, 0 replies; 3+ messages in thread
From: Jean Louis @ 2023-06-24 19:05 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
* Heime <heimeborgia@protonmail.com> [2023-06-15 13:21]:
>
> 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.
I see the header line displayed.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ 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).