From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: output data into table Date: Tue, 27 Dec 2011 11:38:30 +0800 Message-ID: <87aa6en0p5.fsf@ericabrahamsen.net> References: <87y5tzw1m0.fsf@cica.brc> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1324957174 21715 80.91.229.12 (27 Dec 2011 03:39:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 27 Dec 2011 03:39:34 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 27 04:39:30 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RfNsu-0007qq-T5 for geh-help-gnu-emacs@m.gmane.org; Tue, 27 Dec 2011 04:39:29 +0100 Original-Received: from localhost ([::1]:50436 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RfNsu-0004Ro-9Y for geh-help-gnu-emacs@m.gmane.org; Mon, 26 Dec 2011 22:39:28 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:39011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RfNsp-0004Rj-J7 for help-gnu-emacs@gnu.org; Mon, 26 Dec 2011 22:39:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RfNsn-00035r-Pq for help-gnu-emacs@gnu.org; Mon, 26 Dec 2011 22:39:23 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:34877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RfNsn-00035d-D4 for help-gnu-emacs@gnu.org; Mon, 26 Dec 2011 22:39:21 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RfNsm-0007Md-AM for help-gnu-emacs@gnu.org; Tue, 27 Dec 2011 04:39:20 +0100 Original-Received: from 114.252.243.244 ([114.252.243.244]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 27 Dec 2011 04:39:20 +0100 Original-Received: from eric by 114.252.243.244 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 27 Dec 2011 04:39:20 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 51 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 114.252.243.244 User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.92 (gnu/linux) Cancel-Lock: sha1:0ZYhblEtdtjGb6c2lCIKD+rvPn0= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:83261 Archived-At: On Tue, Dec 27 2011, Petro Khoroshyy wrote: > Hi all. > I want to build a table similar to the one GNUS uses to display > messages in a newsgroup. > Could somebody direct me to a code example which does it? > Thanks. > P.S. Does anybody knows a dedicated elisp mailinglist or newsgroup? It's hard to know exactly what you want to see -- what's your current difficulty? The basic pattern you want is to loop over elements in a list (each element being a "row" in your table), and then insert each element into the buffer, perhaps after formatting it in some way. Looping over elements in a list is generally done either with setq, mapcar (or mapconcat), or the loop macro in the 'cl package. Gnus does it with setq: (while threads (setq thread (car threads) threads (cdr threads)) ; do something with thread here, probably ending up with insert ) `mapcar' or `mapconcat' wants you to write a function, perhaps one called `my-format-line', and then you call (insert (mapconcat 'my-format-line threads "\n")) That will call `my-format-line' once for every element of `threads', then take all the resulting strings, put newlines between them, and insert them into the buffer. I'm no good at the `loop' macro, look at the documentation (not a great place to start learning elisp!). I'm not sure if this was what you were really asking. As you can see, making a "table" is just a matter of inserting a series of similarly-formatted lines in a buffer. Each line is a table row. Each cell will be one bit of information in the line -- if you're concerned about the cells lining up tidily, you can use the `format' function, which gives you a way to insert a flexible space. Hope that was useful! As always, check the docstrings for all the above-mentioned functions. Yours, Eric -- GNU Emacs 24.0.92.1 (i686-pc-linux-gnu, GTK+ Version 2.24.6) of 2011-12-07 on pellet