From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: How to insert/replace during `org-elemment-map' call? Date: Thu, 07 Aug 2014 13:27:25 +0200 Message-ID: <87d2cca6aq.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFLrO-0003hy-Ef for emacs-orgmode@gnu.org; Thu, 07 Aug 2014 07:28:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XFLrG-0003N5-TO for emacs-orgmode@gnu.org; Thu, 07 Aug 2014 07:27:54 -0400 Received: from plane.gmane.org ([80.91.229.3]:37032) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFLrG-0003Mu-Mn for emacs-orgmode@gnu.org; Thu, 07 Aug 2014 07:27:46 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XFLr8-0002IA-7w for emacs-orgmode@gnu.org; Thu, 07 Aug 2014 13:27:38 +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 ; Thu, 07 Aug 2014 13:27:38 +0200 Received: from tjolitz by g231105104.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 07 Aug 2014 13:27:38 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Hi List, when I change the signature of my new function `tj/rewire-element' by adding an mandatory 'element' argument, it can be used in `org-element-map' calls too: #+begin_src emacs-lisp (defun* tj/rewire-element (element &optional replace &rest args &key type &allow-other-keys) "..." (let* ((elem (or element (org-element-at-point))) ...))) #+end_src e.g. for converting all src-blocks in a buffer to example blocks: #+begin_src emacs-lisp (org-element-map ptree 'src-block (lambda (--elem) (tj/rewire-element --elem nil :type 'example-block :header nil))) #+end_src but the above just returns a list of strings with the created example-blocks because argument 'replace' is nil: ,---- | (tj/rewire-element --elem nil ...) `---- 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? -- cheers, Thorsten