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: Mon, 19 Jun 2023 18:59:28 +0000

------- Original Message -------
On Tuesday, June 20th, 2023 at 6:49 AM, Jean Louis <bugs@gnu.support> wrote:


> * Christopher Dimech dimech@gmx.com [2023-06-18 22:16]:
> 
> > The functions could be difficult to use because of the many calls to your 
> > "rcd-" functions.
> > Perhaps we can come up with something more adept to users to try. Using 
> > same idea of
> > an ID followed by values.
> 
> 
> Yes, good idea. But I did not find use of it for me. All my PostgreSQL 
> database tables follow certain pattern as described by:
> 
> GeDaFe - PostgreSQL Generic Database Interface:
> http://gedafe.github.io/doc/gedafe-sql.en.html
> 
> and should be compatible with the web interface as well in that
> sense. I did not test it for years, since I switched to Emacs
> interface.
> 
> They follow this pattern "mytable_" plus "id", so there is always
> "ID" which serves handy for tabulated-list-mode
> 
> -- ------------------------------------------
> -- ------------ Table mytable
> -- ------------------------------------------
> DROP SEQUENCE mytable_id_seq;
> 
> CREATE TABLE mytable (
> mytable_id SERIAL NOT NULL PRIMARY KEY,
> mytable_uuid UUID NOT NULL DEFAULT gen_random_uuid() UNIQUE,
> mytable_datecreated TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
> mytable_datemodified TIMESTAMP,
> mytable_usercreated TEXT NOT NULL DEFAULT current_user,
> mytable_usermodified TEXT NOT NULL DEFAULT current_user,
> mytable_name TEXT,
> mytable_title TEXT,
> mytable_description TEXT,
> mytable TEXT
> );

How can I adapt the following to print a table with multiple values rather that 
one ?

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

(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)
      (tabulated-list-print) )))




reply via email to

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