From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz <tjolitz@gmail.com> Subject: Re: How to insert/replace during `org-elemment-map' call? Date: Thu, 07 Aug 2014 18:11:17 +0200 Message-ID: <878un09t5m.fsf@gmail.com> References: <87d2cca6aq.fsf@gmail.com> <87k36kmofv.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org> Received: from eggs.gnu.org ([2001:4830:134:3::10]:56920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <geo-emacs-orgmode@m.gmane.org>) id 1XFQI1-0004Lz-J3 for emacs-orgmode@gnu.org; Thu, 07 Aug 2014 12:11:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <geo-emacs-orgmode@m.gmane.org>) id 1XFQHv-0005sH-HY for emacs-orgmode@gnu.org; Thu, 07 Aug 2014 12:11:41 -0400 Received: from plane.gmane.org ([80.91.229.3]:42276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <geo-emacs-orgmode@m.gmane.org>) id 1XFQHv-0005s0-Az for emacs-orgmode@gnu.org; Thu, 07 Aug 2014 12:11:35 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from <geo-emacs-orgmode@m.gmane.org>) id 1XFQHs-0004Rt-Rr for emacs-orgmode@gnu.org; Thu, 07 Aug 2014 18:11:32 +0200 Received: from g231105104.adsl.alicedsl.de ([92.231.105.104]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for <emacs-orgmode@gnu.org>; Thu, 07 Aug 2014 18:11:32 +0200 Received: from tjolitz by g231105104.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for <emacs-orgmode@gnu.org>; Thu, 07 Aug 2014 18:11:32 +0200 List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>, <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe> List-Archive: <http://lists.gnu.org/archive/html/emacs-orgmode> List-Post: <mailto:emacs-orgmode@gnu.org> List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>, <mailto:emacs-orgmode-request@gnu.org?subject=subscribe> Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Nicolas Goaziou <mail@nicolasgoaziou.fr> writes: Hello, > Thorsten Jolitz <tjolitz@gmail.com> writes: > >> When I set that argument to non-nil (t or 'append or 'prepend), things >> stop working because replacing/appending changes the parsed buffer, >> but the :begin and :end properties of the already parsed elements are >> not adjusted and I use them e.g. to delete a region. >> >> Without using the export-framework (which seems overkill in this >> case), is there a way to make this work anyway? > > You can make replacements backwards, i.e., starting from the bottom of > the buffer. Its not really obvious for me how to do that. You mean simply by doing it in 2 steps 1. map parse-tree and get the result list 2. goto point-max of buffer and use the result list to replace mapped elements backwards or rather a 'trick' to make org-element-map process the parse-tree backwards and thus start with replacing the last element? Not sure what this trick would be - partly reverse the parse-tree? -- cheers, Thorsten