From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Programmatically constructing org documents Date: Mon, 27 Jun 2016 13:52:50 -0400 Message-ID: References: <878txr7mrl.fsf@systemreboot.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHaiP-0004RN-5V for emacs-orgmode@gnu.org; Mon, 27 Jun 2016 13:52:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHaiM-0008Jb-Hq for emacs-orgmode@gnu.org; Mon, 27 Jun 2016 13:52:57 -0400 Received: from mail-qk0-x235.google.com ([2607:f8b0:400d:c09::235]:35867) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHaiM-0008JV-D2 for emacs-orgmode@gnu.org; Mon, 27 Jun 2016 13:52:54 -0400 Received: by mail-qk0-x235.google.com with SMTP id p10so218045401qke.3 for ; Mon, 27 Jun 2016 10:52:53 -0700 (PDT) In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "Charles C. Berry" Cc: Arun Isaac , "emacs-orgmode@gnu.org" 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