From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: Can `org-element-map' act on secondary-strings? Date: Mon, 08 Jul 2013 14:06:37 +0200 Message-ID: <87ip0l9rxu.fsf@gmail.com> References: <87li5jrbx3.fsf@gmail.com> <871u7bfw4x.fsf@gmail.com> <87obada5ck.fsf@gmail.com> <87wqp1ec0b.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwADZ-0007xj-Ia for emacs-orgmode@gnu.org; Mon, 08 Jul 2013 08:06:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UwADY-00086S-Bc for emacs-orgmode@gnu.org; Mon, 08 Jul 2013 08:06:57 -0400 Received: from plane.gmane.org ([80.91.229.3]:44568) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwADY-00086H-54 for emacs-orgmode@gnu.org; Mon, 08 Jul 2013 08:06:56 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UwADW-0004Rl-Ec for emacs-orgmode@gnu.org; Mon, 08 Jul 2013 14:06:54 +0200 Received: from e178063147.adsl.alicedsl.de ([85.178.63.147]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 08 Jul 2013 14:06:54 +0200 Received: from tjolitz by e178063147.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 08 Jul 2013 14:06:54 +0200 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: emacs-orgmode@gnu.org Nicolas Goaziou writes: Hello, > All strings contained in an element or a secondary string have a parent > property. Try > > (org-element-map (org-element-parse-buffer) 'plain-text 'identity) > Do you have a simple example showing what you want to achieve? Thanks, the 'plain-text type was what I missed. I used #+begin_src emacs-lisp (append '(org-data) org-element-all-elements org-element-all-objects) #+end_src as types for mapping, but need to add '(plain-text) to the types to access those :parent properties inside text-strings. My use case is to turn a parse tree that is a circular list into a regular list, and it seems that I achieved it now, e.g. using your minimal example #+begin_src org * A B #+end_src I get this "non-circular" parse-tree: #+begin_src emacs-lisp (org-data nil (headline (:raw-value "A" :begin 1 :end 7 :pre-blank 0 :hiddenp nil :contents-begin 5 :contents-end 7 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :quotedp nil :CATEGORY nil :title (#("A" 0 1 (:parent 1))) :parent 0 :elem-id 1) (section (:begin 5 :end 7 :contents-begin 5 :contents-end 7 :post-blank 0 :parent 1 :elem-id 2) (paragraph (:begin 5 :end 7 :contents-begin 5 :contents-end 7 :post-blank 0 :post-affiliated 5 :parent 2 :elem-id 3) #("B" 0 2 (:parent 3)))))) #+end_src I have a special use for this, but maybe this can be useful in other cases too, e.g. when people want to operate directly on the parse-tree and find it more difficult to handle circular-lists than 'normal' lists. -- cheers, Thorsten