From mboxrd@z Thu Jan  1 00:00:00 1970
From: Jos'h Fuller <Jos'h.Fuller@arcproductions.com>
Subject: Re: Tangling without clutter?
Date: Wed, 14 Mar 2012 19:35:32 +0000
Message-ID: <44B0EAE8544C834188E8790873CDE1CC3EA8C0@ARCEXCHANGE.arc.local>
References: <44B0EAE8544C834188E8790873CDE1CC3EA752@ARCEXCHANGE.arc.local>
	<m1ehsv59g1.fsf@tsdye.com>
	<44B0EAE8544C834188E8790873CDE1CC3EA82A@ARCEXCHANGE.arc.local>
	<87y5r30zdd.fsf@gmx.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Return-path: <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org>
Received: from eggs.gnu.org ([208.118.235.92]:53887)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Jos'h.Fuller@arcproductions.com>) id 1S7tze-0006dJ-37
	for emacs-orgmode@gnu.org; Wed, 14 Mar 2012 15:36:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <Jos'h.Fuller@arcproductions.com>) id 1S7tzJ-0001uA-T8
	for emacs-orgmode@gnu.org; Wed, 14 Mar 2012 15:36:17 -0400
Received: from mail.arcproductions.com ([206.191.120.230]:26711)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Jos'h.Fuller@arcproductions.com>) id 1S7tzJ-0001tg-NU
	for emacs-orgmode@gnu.org; Wed, 14 Mar 2012 15:35:57 -0400
In-Reply-To: <87y5r30zdd.fsf@gmx.com>
Content-Language: en-US
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: Eric Schulte <eric.schulte@gmx.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>, "Thomas S. Dye" <tsd@tsdye.com>

Hi!

> > It seems like I almost need some variant of the "tangle" argument to
> > :noweb where syntax references are expanded for evaluation, but not
> > for anything else.
> >
>=20
> Why would you want to tangle out a python src file with an un-expanded
> noweb reference?  Either way, who am I to judge.  I've just added a new
> "eval" option to the noweb header argument which will expand noweb
> references *only* during interactive evaluation.

Please allow me to explain, I think it's a legitimate use case...

I would like to provide a listing of a Python function, then later in the d=
ocument show a demonstration of how it's used. I just did this when prepari=
ng some documentation for another programmer who is porting an application =
between languages.=20

So I listed the function, then after a discussion, I had a demonstration of=
 how to use the function. I wanted the output from the demonstration to be =
"live", generated from the demonstration code. Therefore, I needed to refer=
ence the function defined above. Unfortunately, the reference was expanded =
during export so that the same block of code appeared /twice/, presenting t=
he reader with something like this:

: Here's a function:
:  def gorking():
:   return "gork"
:
: Here's how to use the function:
:  def gorking():
:   return "gork"
:
:  print gorking()
:=20
: Which gives us:
:  gork

As you can see, it's rather clumsy to have the function in the output twice=
. It's not too bad for this example, but anything more than a few lines bec=
omes quite a distraction! This would have been preferable:

: Here's a function:
:  def gorking():
:   return "gork"
:
: Here's how to use the function:
:  <<function-gorking>>
:=20
:  print gorking()
:=20
: Which gives us:
:  gork

The original %.org file would look like this:

: Here's a function:
:  #+name: function-gorking
:  #+begin_src python :tangle yes
:  def gorking():
:   return "gork"
:  #+end_src
:
: Here's how to use the function:
:  #+name: function-gorking-demo
:  #+begin_src python :tangle yes
:  <<function-gorking>>
:
:  print gorking()
:  #+end_src
:=20
: Which gives us:
:  #+results: function-gorking-demo
:  gork

Does that explain it better?

Thanks!

Jos'h