all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* output data into table
@ 2011-12-26 19:53 Petro Khoroshyy
  2011-12-27  3:38 ` Eric Abrahamsen
  0 siblings, 1 reply; 2+ messages in thread
From: Petro Khoroshyy @ 2011-12-26 19:53 UTC (permalink / raw
  To: help-gnu-emacs

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?


-- 
Petro Khoroshyy




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: output data into table
  2011-12-26 19:53 output data into table Petro Khoroshyy
@ 2011-12-27  3:38 ` Eric Abrahamsen
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Abrahamsen @ 2011-12-27  3:38 UTC (permalink / raw
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-27  3:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-26 19:53 output data into table Petro Khoroshyy
2011-12-27  3:38 ` Eric Abrahamsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.