[O] Circular lists/shared structures in org-element parse-tree

2013-06-28 Thread Thorsten Jolitz

Hi List, 

I wonder how I can find out in a (elisp) program the points in the parse
tree (returned by org-element-parse-buffer) where shared structures are
used. 

In the read-syntax, its easy to see (especially with `print-circle' set
to non-nil):

#+begin_src emacs-lisp
  #2=(org-data nil #1=(headline (:raw-value header 1
   [...] :parent #2#) [...]  
#+end_src

but when processing the parse tree as a list in elisp, how can I detect the
fact that 

,
| :parent #2#
`

refers to 

,-
| #2=(org-data nil
`-

i.e. points back to an already existing structure?

-- 
cheers,
Thorsten




Re: [O] Circular lists/shared structures in org-element parse-tree

2013-06-28 Thread Daimrod
Thorsten Jolitz tjol...@gmail.com writes:

 Hi List, 

 I wonder how I can find out in a (elisp) program the points in the parse
 tree (returned by org-element-parse-buffer) where shared structures are
 used. 

 In the read-syntax, its easy to see (especially with `print-circle' set
 to non-nil):

 #+begin_src emacs-lisp
   #2=(org-data nil #1=(headline (:raw-value header 1
[...] :parent #2#) [...]  
 #+end_src

 but when processing the parse tree as a list in elisp, how can I detect the
 fact that 

 ,
 | :parent #2#
 `

 refers to 

 ,-
 | #2=(org-data nil
 `-

 i.e. points back to an already existing structure?

AFAIK you have to track all pointers inspected to see if one has already
be seen.

For example, I've implemented a version of equal[1] to compare this kind
of lists (to add tests to org-sync).

[1] https://github.com/daimrod/Emacs-config/blob/master/elisp/dmd-utils.el#L25

-- 
Daimrod/Greg


signature.asc
Description: PGP signature


Re: [O] Circular lists/shared structures in org-element parse-tree

2013-06-28 Thread Thorsten Jolitz
Daimrod daim...@gmail.com writes:

 Thorsten Jolitz tjol...@gmail.com writes:

[...]

 but when processing the parse tree as a list in elisp, how can I
 detect the fact that

 ,
 | :parent #2#
 `

 refers to 

 ,-
 | #2=(org-data nil
 `-

 i.e. points back to an already existing structure?

 AFAIK you have to track all pointers inspected to see if one has already
 be seen.

 For example, I've implemented a version of equal[1] to compare this kind
 of lists (to add tests to org-sync).

 [1]
 https://github.com/daimrod/Emacs-config/blob/master/elisp/dmd-utils.el#L25

Oh my ... I knew this would complicate my life a bit ...

Thanks for the link, this example function is indeed very helpful. 

-- 
cheers,
Thorsten