emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Kaushal Modi <kaushal.modi@gmail.com>
Cc: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: Noweb blocks duplicate during Org export if part of #+include
Date: Sat, 08 Dec 2018 10:42:05 +0100	[thread overview]
Message-ID: <87wookfj82.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CAFyQvY180O5DBwVou3f647E2L9FVukovNpSHzjKBODdkULuRkw@mail.gmail.com> (Kaushal Modi's message of "Thu, 6 Dec 2018 09:34:22 -0500")

Hello,

Kaushal Modi <kaushal.modi@gmail.com> 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 <<some_snippet>> 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
> <<some_snippet>> 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 "<<some_snippet>".

In a nutshell, that can be surprising, but this is to be expected.

Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2018-12-08  9:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06 14:34 Noweb blocks duplicate during Org export if part of #+include Kaushal Modi
2018-12-08  9:42 ` Nicolas Goaziou [this message]
2018-12-12 18:50   ` Kaushal Modi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wookfj82.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=kaushal.modi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).