From: Eric Schulte <eric.schulte@gmx.com>
To: Jos'h Fuller <Jos'h.Fuller@arcproductions.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>,
"Thomas S. Dye" <tsd@tsdye.com>
Subject: Re: Tangling without clutter?
Date: Wed, 14 Mar 2012 14:34:43 -0400 [thread overview]
Message-ID: <878vj3ni9o.fsf@gmx.com> (raw)
In-Reply-To: <44B0EAE8544C834188E8790873CDE1CC3EA8C0@ARCEXCHANGE.arc.local> (Jos'h Fuller's message of "Wed, 14 Mar 2012 19:35:32 +0000")
Jos'h Fuller <Jos'h.Fuller@arcproductions.com> writes:
> 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.
>> >
>>
>> 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 document show a demonstration of how it's used. I just did this
> when preparing some documentation for another programmer who is
> porting an application between languages.
>
> 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 reference the function defined
> above. Unfortunately, the reference was expanded during export so that
> the same block of code appeared /twice/, presenting the 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()
> :
> : 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 becomes 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>>
> :
> : print gorking()
> :
> : 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
> :
> : Which gives us:
> : #+results: function-gorking-demo
> : gork
>
> Does that explain it better?
>
Yes, although it seems that the existing "no-export" or "strip-export"
options to the :noweb header argument may better suit your purposes.
These are described in the Org-mode manual, however, they are not
mentioned in the online version of the manual which is out of date.
Cheers,
>
> Thanks!
>
> Jos'h
>
>
>
--
Eric Schulte
http://cs.unm.edu/~eschulte/
next prev parent reply other threads:[~2012-03-14 20:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-14 17:34 Tangling without clutter? Jos'h Fuller
2012-03-14 18:22 ` Thomas S. Dye
2012-03-14 18:39 ` Jos'h Fuller
2012-03-14 19:13 ` Eric Schulte
2012-03-14 19:35 ` Jos'h Fuller
2012-03-14 18:34 ` Eric Schulte [this message]
2012-03-14 22:08 ` Jos'h Fuller
2012-03-14 20:52 ` Eric Schulte
2012-03-15 6:25 ` Viktor Rosenfeld
2012-03-15 8:42 ` Jacek Generowicz
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878vj3ni9o.fsf@gmx.com \
--to=eric.schulte@gmx.com \
--cc=Jos'h.Fuller@arcproductions.com \
--cc=emacs-orgmode@gnu.org \
--cc=tsd@tsdye.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.