From: Ihor Radchenko <yantar92@posteo.net>
To: bvchgvbt@mail.com
Cc: orgmode ml <emacs-orgmode@gnu.org>
Subject: Re: Modifying the parse tree
Date: Thu, 25 May 2023 10:55:58 +0000 [thread overview]
Message-ID: <87wn0wwugx.fsf@localhost> (raw)
In-Reply-To: <trinity-3d7b844d-b932-4f84-8609-42f8bfa67b2b-1685010173855@3c-app-mailcom-lxa13>
bvchgvbt@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>
next prev parent reply other threads:[~2023-05-25 10:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 10:22 Modifying the parse tree bvchgvbt
2023-05-25 10:55 ` Ihor Radchenko [this message]
2023-05-25 11:15 ` bvchgvbt
2023-05-25 11:29 ` Ihor Radchenko
2023-05-26 11:27 ` bvchgvbt
2023-05-26 14:35 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wn0wwugx.fsf@localhost \
--to=yantar92@posteo.net \
--cc=bvchgvbt@mail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.