Skip to content

Instantly share code, notes, and snippets.

View linktohack's full-sized avatar

Quang-Linh LE linktohack

View GitHub Profile
@donlindsay
donlindsay / org-as-json-to-file
Created January 26, 2015 02:42
org-as-json-to-file
(require 'json)
(defun org-as-json-to-file (&optional path)
"Export the current Org-mode buffer as JSON to the supplied PATH."
(interactive "Fwrite to file: ")
(let ((tree (org-element-parse-buffer)))
(org-element-map tree
(append org-element-all-objects org-element-all-elements)
(lambda (el) (org-element-put-property el :parent nil)))
(with-temp-file path
(insert (json-encode tree)))))