From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher Dimech Newsgroups: gmane.emacs.help Subject: Re: Format of lists and alists required for displaying lists of tabulated data Date: Sun, 18 Jun 2023 21:16:01 +0200 Message-ID: References: <648d6296.050a0220.f0b55.8bfc@mx.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32087"; mail-complaints-to="usenet@ciao.gmane.io" Cc: uzibalqa , Bruno Barbier , uzibalqa via Users list for the GNU Emacs text editor To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 18 21:17:09 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qAxtc-00084f-Cz for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 18 Jun 2023 21:17:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qAxtB-00081K-V7; Sun, 18 Jun 2023 15:16:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qAxtA-00080t-2X for help-gnu-emacs@gnu.org; Sun, 18 Jun 2023 15:16:40 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qAxt8-0003fi-4v for help-gnu-emacs@gnu.org; Sun, 18 Jun 2023 15:16:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.com; s=s31663417; t=1687115761; x=1687720561; i=dimech@gmx.com; bh=QI2oYgJdqX2dcZnadaUpeHVFernexVij6RoOo5c/WSE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=KcHq741eiJGb6psYOGY3WvQTgj95yAKTJTtLkSQ7twYU30HbqK6urdLGsA9LMVxpPKInMSa /A5U9tR2WkL0ffWnnUfNI0aERmIAN80HAO0NWX+aRVilUgBl79cGdThVnDO/ZElS7K4ctp5GC eNeYS/K3d4JG36ukaGDPUofAol70kJSus5nUK7/L1OJU78fL8ZdI7aIB63D3o5eg/Ug0erW3y JbQpe0GHNiQdNVof0lKwyRdstj1lI/h89GIMGUffHnaUM6Fb4CuUaVHRzfAhcErb75W85nepI vNnO2kt0mJjiDLoLKJHjKQsddaFv6YvHIhk/szRt5iCdcRAWdKRA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from [92.251.127.164] ([92.251.127.164]) by web-mail.gmx.net (3c-app-mailcom-bs02.server.lan [172.19.170.129]) (via HTTP); Sun, 18 Jun 2023 21:16:01 +0200 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:Ls90xdNN7xx8o1I0wfPKSkMe3z5/gvWq/QQVtdhLO/K1IJC9KNL5ktjNF3eCMkcV1+21Q qiA4TTA3SZ/mzJ/qEe+WQO/fFJF/R02NpInNY4hkraqT0/2UqHK9CAmQ57KpBjNBQNa9vkhXqgzH q4JgakdMN3RU8jIpB1Inji4vrTPbLg5t4miuR5IXs7cEn3z58zzUpFZvna9WH15yM2KJjdQYbN7l n9kLujUpSlyX4kJEfT4uvk+GFIR9txte7TE/YMXTuLftM3ev7Lafzgg0upltl4vazPZBcHZyiljr BM= UI-OutboundReport: notjunk:1;M01:P0:WTwvTh1Nb9E=;mDkt/FAZveGUnwDZp2wf4nkDdiC 1dJgwFpUdedq/d+qRoxvS/b+o9bInzbjcdrSxFaEBv2UaWYorJxLKD4ZCl/wx7MiRFhYJRzr7 9F2GYYWgsT7FzP66SGG07tcRxkmDWyxsem55mx+CX9rRNyMf+3fx5FnyBDg6oddYLPt35CoV+ Br0BkkOarUISXdDWw7ZtW5Rs/X2NXuwtBNx+UJYO2OdjMwHf7s1e1LppsKMj+oCvVjse+dnaw EsdzK5OcUPKvH3XoXzgP65SuVVWMHn/QMm0vDpJ3DyV/vEdAvk5Nwn6HvnvOcoyabibdZX4OZ UA6ZK1tXTZJzehDUYEQvC+ouoge/eSs5IKJVD8+Z1UecQs/D7c8FhPPyCPE27J4LTCNROQjW/ v0UkdYlM8vdCIqdZJttRfmq2GITuj8UDu1oZHQJ8iDsfhksA1cL1sq/2uHQBJ9BuiE+UlMKDL VkYsFWb8LoiO2ra3X3pGtZfnA7LZZkyePg2hsi+N2UsnmV+jLhOPxlnxFqJxFZC/uujvvkr0e k59/HHkMXfFWYkGFnGM/MlMk4CuiMMdeA1StcY+X/xKqs4SriwomFsVJDANrD4Q8rFF/Jkkx1 XLQJrtc0W/o6B0xn6jueka3qdNZjnOwEUFbqk0+ZKa3svd4diDGgvddcrOZAPJ4Y5qb3Ygakb CAlzrme7jQplAm1xkwplaoeiiledvRZzqMGX08rlrdDP5aVyGBPyzZYTU91sYhB7olVD5vfTN jKnaPeb1zWZj70H4fXyMiswd621p9G6xENJu0OI9gwVk3lpupyBtL0ZtyoReLmjD5RcjjcaH Received-SPF: pass client-ip=212.227.15.15; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:143994 Archived-At: > Sent: Monday, June 19, 2023 at 3:31 AM > From: "Jean Louis" > To: "uzibalqa" > Cc: "Bruno Barbier" , "uzibalqa via Users list for = the GNU Emacs text editor" > Subject: Re: Format of lists and alists required for displaying lists of= tabulated data > > * uzibalqa [2023-06-17 16:28]: > > It would also be handy to have some conversion functions that takes a = normal > > list or alist, and converts them to ones suitable for tabulated-list-e= ntries. > > Those functions would be too much specific, and you can do those functio= ns. > > I have functions like these which are using SQL which get expanded into = tabulated-list-mode: > > (rcd-db-sql-report title sql cf-people-tabulated-format-with-people-list= "people" nil refresh-function '(">>>UNKNOWN<<<") return-function) > > Or like this: (cf-people-by-id-list (list introducer)) which would show = tabulated-list-format by list of people IDs > > My SQL has always ID followed by values, so here is the key function tha= t converts it: 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 s= ame idea of an ID followed by values. > (defun rcd-db-sql-report (title sql format table sort-key refresh &optio= nal highlight-list return-function) > "Prepare SQL for tabulated list report." > (let* ((entries-1 (rcd-sql sql cf-db)) > (entries-2 > (mapcar #'(lambda (i) > (list > (elt i 0) > (vconcat > (append (list > (cond ((numberp (elt i 0)) (number-to-string (elt i 0))) > (t (elt i 0)))) > (cdr (append i nil)))))) > entries-1))) > (cond (entries-1 (rcd-db-report title entries-2 format "pg" 'cf-db t= able sort-key refresh highlight-list nil nil return-function)) > (t (rcd-warning-message (format "No entries for report `%s'" title)))= ))) > > (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 'e= qual) 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)))) > > The above workflow shall serve only as example to your own functions. > > -- > Jean > > Take action in Free Software Foundation campaigns: > https://www.fsf.org/campaigns > > In support of Richard M. Stallman > https://stallmansupport.org/ > >