From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id A6HNMws+b2TvSwEASxT56A (envelope-from ) for ; Thu, 25 May 2023 12:52:59 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id aCh5Mgs+b2RiKAAA9RJhRA (envelope-from ) for ; Thu, 25 May 2023 12:52:59 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 963C5129FE for ; Thu, 25 May 2023 12:52:59 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q28Ze-0002Zj-9T; Thu, 25 May 2023 06:52:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q28Zd-0002ZZ-JC for emacs-orgmode@gnu.org; Thu, 25 May 2023 06:52:01 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q28ZS-0006tZ-7u for emacs-orgmode@gnu.org; Thu, 25 May 2023 06:52:01 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 8C677240101 for ; Thu, 25 May 2023 12:51:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1685011908; bh=6YZ+/i2QDvfSO35ZUuyGXuupBkpFAhppxte2oVLo3Vg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=OXywc7MpQiTFmg/39A146/CkOsQ0z/nga/G2epuGhyk+H2ySIxEklVWq+RfT7eLqE 4WuOmrQKEJGn60Rvf6dFYAL1QreV3UtYXfpe877hu9QUTozryW02/bUX5WGtGYRQOK HMR+/s/oOmARYtRGlMMl4wqtWyqUM9NeGqEBpp3flrB+5vtEbAW0UTG5T+KPRAFY9j HR6bPGbzwCkaXmnPfydnRob3dsgJNQ4NuAUDU4hemnzIWGCoxSKocIiDj2samVYmmc FMdoGxlf1UTFI6jVSPNrEwoYlfeILoG5WuNOdVwg6ivl1tXqWSfbO/h/UjISGBz6Ib ZseCqAMCzG9qw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QRlH80nM0z6tvd; Thu, 25 May 2023 12:51:48 +0200 (CEST) From: Ihor Radchenko To: bvchgvbt@mail.com Cc: orgmode ml Subject: Re: Modifying the parse tree In-Reply-To: References: Date: Thu, 25 May 2023 10:55:58 +0000 Message-ID: <87wn0wwugx.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1685011979; a=rsa-sha256; cv=none; b=fSAo9GgYOsBkTiJ7ed1KaGdArC7IHjaFnqHpv4TlSsr/ELPA3MixzUWSI7BTssx0hPSZRq 7QEC4RC1ajaNxPbeXcmFHuw0YUr2JvZhgy1x0xuvRgMrgsGRZUCChBKYEWdCWU53gOp6bQ dvKk9TbqIxNJXD25YdinmcUnnfm5KOEzNSsRXcTSaqahEIF4QIJRlChYasF7bzhogSozCf 0o6FS952MTVsZTbhcxOhN/ZsnHSXBD08O+68bkLMQJo9WXcHOO8KoYMiVW5/IQHIHUOVxp DqT1jMVGfjLRNKPuQ65GVbhKPmoLf9D33749ZSs1mbzTcKuSiG5l2r1VIV6+sw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=OXywc7Mp; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1685011979; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=8nZyUVuxxLXJL7NDDxnJatTE9EbUo6CcLD22oCVyjJQ=; b=JRvlYd53a+Sx0p0Z6xDylD0Rryv9MH1kC1GFZBqRoCOPZ+T+OORolk0t47hds+5MWC1veR zu1cQf453znjr+NckehyASTfC9BwHA2QfU1PPptDmdG0pxjI1knU4LqAL4qiVcEux52Rcx wtg+QUbuvjiVH5juUH/5Ep2PyQmYFR6aTletAm4ZIILYV31kbxs2w0ppsVUHnFWclXljEY AiY39nxVgsrZC0PWFe11lYIClbeaK8s0Dekkmq4DHkg4JvlHx+eRjUC8q/8OD3IDr/00jB xkq0g+h3JQtjIz839x4JEzwDwSDLb8JQtFHVFH3q6I/TiXoVFjv3PzUmkD3+SQ== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=OXywc7Mp; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -6.12 X-Spam-Score: -6.12 X-Migadu-Queue-Id: 963C5129FE X-TUID: J7UX3apEPtJ5 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 . Support Org development at , or support my work at