From: Jean Louis <bugs@gnu.support>
To: Heime <heimeborgia@protonmail.com>
Cc: Heime via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org>
Subject: Re: Printing a header with tabulated-list-mode
Date: Sat, 24 Jun 2023 22:03:05 +0300 [thread overview]
Message-ID: <ZJc96WYqeNXv08CD@lco.syogm.com> (raw)
In-Reply-To: <PcSl8WursRmUHJWeJHIl6FsXjYh_1l3zwJQaZoNl9hkBXqEzsvRNuYLBqDosazaGmUq5VJrdul6mecXTc5TqmyukiP3q17RxDmQsDBOVKPE=@protonmail.com>
* 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/
next prev parent reply other threads:[~2023-06-24 19:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-15 12:03 Printing a header with tabulated-list-mode Heime
2023-06-24 19:03 ` Jean Louis [this message]
2023-06-24 19:05 ` Jean Louis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZJc96WYqeNXv08CD@lco.syogm.com \
--to=bugs@gnu.support \
--cc=heimeborgia@protonmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).