Eric Schulte <schulte.e...@gmail.com> writes:

> You can use `org-element-parse-buffer' to convert an Emacs Buffer to a
> structured Emacs Lisp object.  At that point you can use existing tools
> for converting lisp to JSON or YAML.  I've used cl-json for Common Lisp,
> I would imagine something similar exists for Emacs Lisp.

Thanks for the suggestion.  I pursued that a bit this weekend.  The
resulting data structure is a Circular Object[1] due to the ":parent"
references.  It seems dealing with this kind of data structure is
somewhat uncommon (or my search-fu lacking), although I do find a recent
reference to it on this mailing list[2].  I also found a "cust-print"[3]
feature from Emacs 19 which has since been removed.  It shows a way to
deal with Circular Objects.  So far it has strongly taxed my poor elisp
skills but I plan to pursue this direction a bit more.

I did try throwing a JSON parser/generator[4] at the output of
org-element-parse-buffer but this failed due to exceeding emacs's
recursion limits.  I think this must be from the ":parent" references
getting recursed on forever.


-Brett.


[1] one must (setq print-circle t) to avoid emacs reader errors
http://www.gnu.org/software/emacs/manual/html_node/elisp/Circular-Objects.html

[2] http://comments.gmane.org/gmane.emacs.orgmode/65999

[3] http://web.mit.edu/dosathena/sandbox/emacs-19.28/lisp/cust-print.el

[4] http://edward.oconnor.cx/2006/03/json.el

Attachment: pgpvW01zMgjgz.pgp
Description: PGP signature

Reply via email to