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 `org-element-parse-buffer'. We generally do not currently have a way to modify Org buffer text from AST. The only way to write the parse tree back is replacing it with the output `org-element-interpret-data'. But be aware that interpreted tree and the original text do not have exact 1-to-1 equivalence. Some whitespace might be lost. > I can see that the tree is modified but it isn't reflected in the buffer > it came from, and furthermore calling org-element-interpret-data on the > modified tree at that stage results in an error: > > "org-element-headline-interpreter: Wrong type argument: wholenump, nil" Which implies that you added invalid headline element to the tree. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>