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 18:39:49 +0000
Message-ID: <44B0EAE8544C834188E8790873CDE1CC3EA82A@ARCEXCHANGE.arc.local>
References: <44B0EAE8544C834188E8790873CDE1CC3EA752@ARCEXCHANGE.arc.local>
	<m1ehsv59g1.fsf@tsdye.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]:54527)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Jos'h.Fuller@arcproductions.com>) id 1S7t7U-0007aQ-Ik
	for emacs-orgmode@gnu.org; Wed, 14 Mar 2012 14:40:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <Jos'h.Fuller@arcproductions.com>) id 1S7t7O-0006E9-1r
	for emacs-orgmode@gnu.org; Wed, 14 Mar 2012 14:40:20 -0400
Received: from mail.arcproductions.com ([206.191.120.230]:10819)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Jos'h.Fuller@arcproductions.com>) id 1S7t7N-0006E0-SX
	for emacs-orgmode@gnu.org; Wed, 14 Mar 2012 14:40:13 -0400
In-Reply-To: <m1ehsv59g1.fsf@tsdye.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: "Thomas S. Dye" <tsd@tsdye.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>

Hi!

> Does the :no-expand header argument do what you want?  See
> http://orgmode.org/manual/no_002dexpand.html#no_002dexpand.

I tried using it like this:

  #+name: function-demo
  #+begin_src python :exports both :noweb yes :results output :no-expand
    <<function-definition>>
   =20
    print entable([["One", 2, 59],["Four", 5, 27], ["Seven", 8, 9]])
  #+end_src

But it didn't seem to affect the results at all. I may be using it wrong, t=
he documentation is a bit sparse, without any examples...

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

Thanks for taking a look!

Jos'h


> -----Original Message-----
> From: Thomas S. Dye [mailto:tsd@tsdye.com]
> Sent: Wednesday, March 14, 2012 2:23 PM
> To: Jos'h Fuller
> Cc: emacs-orgmode@gnu.org
> Subject: Re: Tangling without clutter?
>=20
> Jos'h Fuller <Jos'h.Fuller@arcproductions.com> writes:
>=20
> > Hi!
> >
> > I was writing some documentation about how to use a Python function,
> so I decided to try the tangling feature. However, the result, when
> exported to PDF, is unsatisfactory because the referenced code block is
> included twice -- first in the original location, then again where I
> referenced it with <<function-definition>>.
> >
> > This is, of course, exactly what it needs to do to be able to execute
> the code properly and show the result. But it doesn't look nice. Is
> there any way to suppress the second printing inside the function-demo
> block?
> >
> > If this isn't clear from the example below, I can provide examples of
> the duplication in action as well as what I'd like the output to look
> like.
> >
> > Thanks very much!
> >
> > Example file:
> > #+TITLE:     Tangle Test
> > #+LANGUAGE:  en
> > #+OPTIONS:   H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:nil -:t f:t *:t
> <:t
> > #+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-
> toc
> >
> > * Tangled Code
> >   I want to show the definition of a function first:
> >   #+name: function-definition
> >   #+begin_src python :tangle yes :exports code
> >     def entable(data):
> >         if not data: return "/No data./"
> >
> >         columns =3D len(data[0])
> >         sizes   =3D [0,]*columns
> >         for row in data:
> >             sizes =3D [max(x) for x in zip(sizes, [len(str(t)) for t in
> row])]
> >
> >         format =3D "| " + " | ".join(["%%%ds" % x for x in sizes])+" |"
> >         return "\n".join([format % tuple(row) for row in data])
> >   #+end_src
> >
> >   Now I want to show a demonstration of how the function might be
> >   called. I need the function to be included so that demonstration
> >   code can be executed, but I don't want to include the function
> >   definition twice:
> >
> >   #+name: function-demo
> >   #+begin_src python :tangle yes :exports both :noweb yes :results
> output
> >     <<function-definition>>
> >
> >     print entable([["One", 2, 3],["Four", 5, 6], ["Seven", 8, 9]])
> >   #+end_src
> >
> >   Which gives us this result:
> >
> >   #+results: function-demo
> >   : |   One | 2 | 3 |
> >   : |  Four | 5 | 6 |
> >   : | Seven | 8 | 9 |
> >
> >
> Aloha!
>=20
> Does the :no-expand header argument do what you want?  See
> http://orgmode.org/manual/no_002dexpand.html#no_002dexpand.
>=20
> hth,
> Tom
> --
> Thomas S. Dye
> http://www.tsdye.com