From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Using org-map-entries with org-export-before-processing-hook Date: Wed, 06 Mar 2013 11:13:47 +0100 Message-ID: <87boaw25us.fsf@gmail.com> References: <871ubt8awv.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:38436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDBMM-0000at-Ro for emacs-orgmode@gnu.org; Wed, 06 Mar 2013 05:14:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UDBMG-0007Hq-1j for emacs-orgmode@gnu.org; Wed, 06 Mar 2013 05:14:06 -0500 Received: from mail-wg0-x22a.google.com ([2a00:1450:400c:c00::22a]:65128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDBMF-0007Hb-OP for emacs-orgmode@gnu.org; Wed, 06 Mar 2013 05:13:59 -0500 Received: by mail-wg0-f42.google.com with SMTP id 12so4529372wgh.1 for ; Wed, 06 Mar 2013 02:13:58 -0800 (PST) In-Reply-To: <871ubt8awv.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Wed, 06 Mar 2013 11:28:00 +0800") 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: Eric Abrahamsen Cc: emacs-orgmode@gnu.org Hello, Eric Abrahamsen writes: > I've attached a minimum org file that shows what I'm trying to do: > essentially to attach a hook to the export process that ends up calling > org-map-entries to make alterations to the file just before it's > exported. > > As I've got it now, the hook does change the org buffer, but those > changes are *not* reflected in the exported output. I can only guess > that somehow the export process is able to continue on before the > org-map-entries results are returned? Doesn't seem likely, but... > > This is actually kind of the opposite of what I'd like: to have the > changes *only* reflected in the export, and leave the original buffer > unchanged. On the other hand, I can see what thought and care has gone > into setting up a clone buffer for export (and I do need to rely on > buffer-local variables), so maybe an (undo) is my best solution for > returning the buffer to its pre-export state. > > But I would like the changes to show up in the exported file! The problem is not directly related to the export framework, but to its relationship with `org-map-entries'. If you use the following function: (defun before-export-test (backend) ;; (org-map-entries 'test-map "TODO=\"TODO\"" 'file) (while (re-search-forward "^\\*+ TODO" nil t) (test-map))) it should work. I don't know why `org-map-entries' behaves badly with export. Meanwhile, I suggest to not use this function for export hooks. Regards, -- Nicolas Goaziou