Re: Modifying the parse tree

2023-05-26 Thread Ihor Radchenko
bvchg...@mail.com writes: >> Yes, it is invalid. You must always have :level. > > Ah! Thank you! Is there some documentation that explains which properties > each element must have in order to be valid, please? Just https://orgmode.org/worg/dev/org-element-api.html And source code, of course.

Re: Modifying the parse tree

2023-05-26 Thread bvchgvbt
> "Ihor Radchenko" wrote: > >> Which implies that you added invalid headline element to the tree. > > > > Hmm. Does > > headline (:title hello :todo-keyword TODO :todo-type todo) > > look valid to you as a minimal TODO-type headline? Created via: > > > > (let ((todo (org-element-create

Re: Modifying the parse tree

2023-05-25 Thread Ihor Radchenko
bvchg...@mail.com writes: >> But be aware >> that interpreted tree and the original text do not have exact 1-to-1 >> equivalence. Some whitespace might be lost. > > Only whitespace? I can live with that. I know for sure about whitespace. We have some tests for interpreter, but this has never

Re: Modifying the parse tree

2023-05-25 Thread bvchgvbt
"Ihor Radchenko" wrote: > bvchg...@mail.com writes: > Parse tree is not kept in sync with the original buffer when you > retrieve it by `org-element-parse-buffer'. Okay, thanks. I thought that might be the case, but couldn't be sure. > We generally do not currently > have a way to modify Org

Re: Modifying the parse tree

2023-05-25 Thread Ihor Radchenko
bvchg...@mail.com writes: > After calling, say, org-element-adopt-elements, do I (or rather my code) > have to do anything to make the modified tree apply to the Org document/ > buffer that the tree came from? Yes. Parse tree is not kept in sync with the original buffer when you retrieve it by

Modifying the parse tree

2023-05-25 Thread bvchgvbt
After calling, say, org-element-adopt-elements, do I (or rather my code) have to do anything to make the modified tree apply to the Org document/ buffer that the tree came from? I can see that the tree is modified but it isn't reflected in the buffer it came from, and furthermore calling