From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vitalie Spinu Subject: Re: org-export: how to copy the parsed tree? Date: Sat, 01 Mar 2014 10:24:50 -0800 Message-ID: <87ob1pepzh.fsf@gmail.com> References: <87wqgeemto.fsf@gmail.com> <87vbvyp2v5.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJoal-0000Zx-Du for emacs-orgmode@gnu.org; Sat, 01 Mar 2014 13:24:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJoak-0000sE-Fl for emacs-orgmode@gnu.org; Sat, 01 Mar 2014 13:24:55 -0500 Received: from mail-pa0-x230.google.com ([2607:f8b0:400e:c03::230]:48500) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJoak-0000rv-7b for emacs-orgmode@gnu.org; Sat, 01 Mar 2014 13:24:54 -0500 Received: by mail-pa0-f48.google.com with SMTP id kx10so2131364pab.7 for ; Sat, 01 Mar 2014 10:24:52 -0800 (PST) In-Reply-To: <87vbvyp2v5.fsf@gmail.com> (Nicolas Goaziou's message of "Sat, 01 Mar 2014 12:36:30 +0100") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org >>> Nicolas Goaziou on Sat, 01 Mar 2014 12:36:30 +0100 wrote: > Hello, > Vitalie Spinu writes: >> Is there an easy way to copy org sub-tree in :filter-parse-tree? >> >> The structure of the parsed tree is somewhat complicated with recursive >> references to parents in multiple places. So, copy-tree infloops. > This is not really an answer to your question, but do you really need to > copy the full tree? There are tools to modify it. You can also build > a new parse tree and return it. Thanks Nocolas. I need to copy only a subtree associated with a headline. In a nutshell I need to "flatten" the tree of headlines for the csv type exporter. That is, I need to replicate the parent headlines across the children. For example * H1 bla bla ** HA some text ** HB some other text would translate into * H1 bla bla ** HA some text * H1 bla bla ** HB some other text I played with org-element-extract-element, org-element-set-contents and org-element-insert-before but failed a big deal. Main problem seems to be the lack of uniform interface to handle parents in connection to secondary elements (which I don't understand at this point). Is headline a secondary element? The :parent seems to be stored in 2 places for the headline, in the headline itself and in the :title. Most of the org code uses org-element-put-property and org-element-property to access the parent but some code like org-element-extract-element uses :parent from :title. This makes it difficult to program as there are no explicit getter/setter for the parent. BTW, is there a way to pretty print the org tree? I think that's the main barrier for me in understanding how it all works. Thanks, Vitalie