emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Can `org-element-map' act on secondary-strings?


From: Thorsten Jolitz
Subject: Re: [O] Can `org-element-map' act on secondary-strings?
Date: Mon, 08 Jul 2013 14:06:37 +0200
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux)

Nicolas Goaziou <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]