org-ml
org-ml copied to clipboard
stray `:END:` markers are duplicated on `headline-set-node-property`
Edit: again, this seems to be an org-element bug? The org-format is also not very strict and/or explicit on this...
Evalute
(org-ml-update* (org-ml-headline-set-node-property "TEST" "TEST" it) (org-ml-parse-this-subtree))
on
* test
:END:
results in:
* test
:PROPERTIES:
:TEST: TEST
:END:
:END:
:END:
Subsequent evaluations of the same quickly spiral into oblivion:
* test
:PROPERTIES:
:TEST: TEST
:END:
:PROPERTIES:
:TEST: TEST
:END:
:END:
:END:
:END:
:END:
$ ls -alh
-rwxr-xr-x 1 hrehfeld hrehfeld 4.1M Oct 31 22:59 test.org
(org-ml-parse-this-subtree) and (org-element-parse-buffer) parse a drawer named END:
(headline
(:raw-value "TEST" :begin 1 :end 15 :pre-blank 1 :contents-begin 9 :contents-end 15 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title (#("TEST" 0 4 (:parent #0))) :parent nil)
(section (:begin 9 :end 15 :contents-begin 9 :contents-end 15 :post-blank 0 :post-affiliated 9 :parent #0)
(drawer (:begin 9 :end 15 :drawer-name "END" :contents-begin nil :contents-end nil :post-blank 0 :post-affiliated 9 :parent #1))))
Interestingly, this doesn't duplicate:
(org-ml-update* #'identity (org-ml-parse-this-subtree))
but this does:
(org-ml-insert-tail (point) (org-ml-parse-this-subtree))
So does this:
(org-ml-update* (org-ml-headline-set-title! "TEST" nil it) (org-ml-parse-this-subtree))
Maybe because the first doesn't update at all?
This seems like an upstream error. It doesn't make sense for org-element to parse ":END:" (without another ":END:") as a drawer named "END". The reason why the identity doesn't do it is because there is a check in org-ml-update that will noop if the final output is the same as the input.