Yeah, pretty much! Thanks for the example. As for control sum, perhaps file and directory mtimes would be sufficient. >From experience, something like (secure-hash 'sha1) takes whole seconds to do on all my files, which would reduce the frequency of times you can check for changes if you don't want to eat battery.
> Is the idea to memoize the output of `org-element-parse-buffer` in a file > using > a change date or control sum to verify the content hasn't changed, so as to > be > able to reuse that later, eliminating the need to parse the org-file again, > like in the minimal naive example below? > > #+begin_src emacs-lisp :lexical t :wrap example :results raw > ;; I use org-mode "83a55c6fe", the example might not work > ;; with earlier version. > (let* > ((org-content > (mapconcat (function identity) > '( > "# I'm a comment" nil > ":PROPERTIES:" > ":ID: 463e4d2b-65d7-40ea-ad2d-80abd9edbeff" > ":special_property: cool special property" > ":END:" > "#+title: cool title" nil > "* hello" > "hello" nil > ) > "\n")) > > (ast (with-temp-buffer > (insert org-content) > (org-mode) > (org-element-parse-buffer))) > > (print-circle t) > > (as-a-string (prin1-to-string ast)) > > (cleaned-string > (replace-regexp-in-string > "#<killed buffer>" "\"quux\"" as-a-string)) > > ;; Here, you can save the string to a file. > ;; Then, you can reuse the string to convert it back into an AST > ;; without having to parse the org-file again. > > (ast-out (car (read-from-string cleaned-string))) > > (new-content (org-element-interpret-data ast-out))) > > (princ new-content)) > #+end_src > > #+RESULTS: > #+begin_example > # I'm a comment > > :PROPERTIES: > :ID: 463e4d2b-65d7-40ea-ad2d-80abd9edbeff > :special_property: cool special property > :END: > ,#+title: cool title > > ,* hello > hello > #+end_example > > Chris