emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Vitalie Spinu <spinuvit@gmail.com>
To: Nicolas Goaziou <n.goaziou@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-export: how to copy the parsed tree?
Date: Sat, 01 Mar 2014 10:24:50 -0800	[thread overview]
Message-ID: <87ob1pepzh.fsf@gmail.com> (raw)
In-Reply-To: <87vbvyp2v5.fsf@gmail.com> (Nicolas Goaziou's message of "Sat, 01 Mar 2014 12:36:30 +0100")

 >>> Nicolas Goaziou on Sat, 01 Mar 2014 12:36:30 +0100 wrote:

 > Hello,
 > Vitalie Spinu <spinuvit@gmail.com> 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

  reply	other threads:[~2014-03-01 18:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-01  1:20 org-export: how to copy the parsed tree? Vitalie Spinu
2014-03-01  8:45 ` Thorsten Jolitz
2014-03-01 10:21   ` Thorsten Jolitz
2014-03-01 11:36 ` Nicolas Goaziou
2014-03-01 18:24   ` Vitalie Spinu [this message]
2014-03-01 21:02     ` Nicolas Goaziou
2014-03-01 21:21       ` Vitalie Spinu
2014-03-02  9:13         ` Nicolas Goaziou

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=87ob1pepzh.fsf@gmail.com \
    --to=spinuvit@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    /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).