emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: "Charles C. Berry" <ccberry@ucsd.edu>
Cc: Arun Isaac <arunisaac@systemreboot.net>,
	"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Programmatically constructing org documents
Date: Mon, 27 Jun 2016 13:52:50 -0400	[thread overview]
Message-ID: <m2shvy7c3x.fsf@Johns-MacBook-Air.local> (raw)
In-Reply-To: <alpine.OSX.2.20.1606270850001.536@charles-berrys-macbook.local>

Cool, thanks for the tip.

So, you can build a table like this:

#+BEGIN_SRC emacs-lisp
(org-element--interpret-data-1
 '((table (:caption (((("Some interesting thing."))))) (table-row '()
			 (table-cell '() ("5"))
			 (table-cell '() ("6")))
	  (table-row '()
		     (table-cell '() ("6"))
		     (table-cell '() ("7")))))
 nil)
#+END_SRC

that is sure to be handy one day ;)


Charles C. Berry writes:

> On Mon, 27 Jun 2016, John Kitchin wrote:
>
>> After some more thought, I am not sure it is possible to setup just a
>> parse tree for this. It works ok for src blocks, e.g.
>>
> [deleted]
>
>> On the other hand, it isn't clear how to use this to make a table.
>>
>> e.g. this table:
>>
>> | 5 | 6 |
>> | 6 | 7 |
>>
>> was represented as an element like this.
>>
>> (table
>> (:begin 5133 :end 5154 :type org :tblfm nil :contents-begin 5133 :contents-end 5153 :value nil :post-blank 1 :post-affiliated 5133 :parent nil))
>>
>> There is no data in that representation, just points in the buffer where
>> the data is. Does anyone know how to do this?
>
>
> Use (org-element-parse-buffer) to get the table-row and table-cell elements, too.
>
> --8<---------------cut here---------------start------------->8---
>
> | 5 | 6 |
> | 6 | 7 |
>
>
> #+BEGIN_SRC emacs-lisp
>    (org-element-map (org-element-parse-buffer) 'table-cell 'cddr)
> #+END_SRC
>
> --8<---------------cut here---------------end--------------->8---
>
>
> HTH,
>
> Chuck


-- 
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

  reply	other threads:[~2016-06-27 17:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-24 14:16 Programmatically constructing org documents Arun Isaac
2016-06-26 15:12 ` John Kitchin
2016-06-26 19:50   ` Arun Isaac
2016-06-27 12:12     ` John Kitchin
2016-06-27 16:13       ` Charles C. Berry
2016-06-27 17:52         ` John Kitchin [this message]
2016-06-27 19:19       ` Samuel W. Flint
2016-06-28  3:15         ` Arun Isaac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2shvy7c3x.fsf@Johns-MacBook-Air.local \
    --to=jkitchin@andrew.cmu.edu \
    --cc=arunisaac@systemreboot.net \
    --cc=ccberry@ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).