Nicolas Goaziou <[email protected]> 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