Let's say I have an org-mode
file at ~/myorg.org
, looking like this:
* TODO My TODO list
** TODO Play games
** TODO Build a boat
** DONE Do something else
Now I want to modify this document using org-element
. Let's say I want to change all TODO items to DONE. I thought something like this would work:
(with-current-buffer (find-file-noselect "~/myorg.org")
(org-element-map (org-element-parse-buffer) 'headline
(lambda (h)
(org-element-put-property h :todo-keyword "DONE")))
(save-buffer))
The structure returned from org-element-map
seems fine, but the code doesn't modify the file. Do I have to replace the whole buffer text using org-element-interpret-data
, or is there some other way?