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

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

Re: Format of lists and alists required for displaying lists of tabulate


From: uzibalqa
Subject: Re: Format of lists and alists required for displaying lists of tabulated data
Date: Sun, 18 Jun 2023 10:36:36 +0000



------- Original Message -------
On Sunday, June 18th, 2023 at 8:54 AM, Tim Landscheidt <tim@tim-landscheidt.de> 
wrote:


> uzibalqa uzibalqa@proton.me wrote:
> 
> > > > The file tabulated-list.el does not describe the format of lists and 
> > > > alists
> > > > required for displaying lists of tabulated data.
> > > > 
> > > > Could some information be added, please ?
> 
> > > The documentation of 'tabulated-list-mode'
> > > (describe-function 'tabulated-list-mode)
> 
> > > points to the documentation of 'tabulated-list-format' and the
> > > documentation of 'tabulated-list-entries'.
> 
> > > Is that what you're looking for ?
> 
> > Yes, the description of tabulated-list-entries states that the input
> > if a list, each element has the form (ID [DESC1 ... DESCN]).
> 
> > […]
> 
> 
> Not only that, but it also explains what ID is and what DESC
> can be and what effects it has. So what data have you set
> tabulated-list-entries to and how does it fail to do what
> you want?
> 
> Tim

I am trying to print a header and also some text to the buffer, and
not being successful.



(defun tlprint-alist (alist &optional outbufr keytl valtl)
  "Print an associated list via `tabulated-list-print'."

  (let*
      ( (bufr (or outbufr (get-buffer-create "*Alist2*")))
        (keytl (or keytl "Key Title"))
        (valtl (or valtl "Value Title")) )

    (with-current-buffer bufr
      (tabulated-list-mode)
      (setq buffer-read-only nil)
      (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 (dyad)
                      (list (car dyad) (cdr dyad)))
                    alist))
      (tabulated-list-init-header)
      (insert keytl valtl "\n")
      (insert "TEST \n")
      (princ "Text to be written" (current-buffer))
      (tabulated-list-print) )))

(setq foo '((a . ["aa1" "aa2"]) (b . ["bb1" "bb2"]) (c . ["cc1" "cc2"])))
(tlprint-alist foo)




reply via email to

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