From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Noweb blocks duplicate during Org export if part of #+include Date: Sat, 08 Dec 2018 10:42:05 +0100 Message-ID: <87wookfj82.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVZ7l-0008Hx-2d for emacs-orgmode@gnu.org; Sat, 08 Dec 2018 04:42:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVZ7h-0007F4-IV for emacs-orgmode@gnu.org; Sat, 08 Dec 2018 04:42:12 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:33997) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gVZ7h-0007Dx-B1 for emacs-orgmode@gnu.org; Sat, 08 Dec 2018 04:42:09 -0500 In-Reply-To: (Kaushal Modi's message of "Thu, 6 Dec 2018 09:34:22 -0500") 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" To: Kaushal Modi Cc: emacs-org list Hello, Kaushal Modi writes: > Here is a MWE: > > 1. With point on the "** Foo" section, running C-c C-e C-s h o, will > result in noweb-duplicate-bug.html with the <> block > expanded only once, as expected. > > 2. But with point on the "* Foo Included" section, running the same > C-c C-e C-s h o, will result in foo_included.html with the > <> block expanded twice! It seems like the Noweb > expansion happens first as usual, and then again when parsing > #+include (which shouldn't happen?). That's not exactly what is happening. INCLUDE keywords are always expanded before Babel kicks in. Moreover, when exporting a subtree, only INCLUDE keywords from the subtree are expanded. So, in your first example, nothing fancy happens. Now, onto the second case. When evaluating Babel code, the whole initial buffer is taken as reference. It allows, for example, to define source blocks in a dedicated section, and export another one that calls them. When the INCLUDE keyword is expanded, there are two ":noweb-ref some_snippet". Even if they are outside the exported subtree, they are still concatenated and used as a replacement for "<". In a nutshell, that can be surprising, but this is to be expected. Regards, -- Nicolas Goaziou