[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Literate Programming - Continue a Source Block?

From: Eric Schulte
Subject: Re: [O] Literate Programming - Continue a Source Block?
Date: Thu, 16 Jun 2011 21:39:53 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Neeum Zawan <address@hidden> writes:

> Eric Schulte <address@hidden> writes:
>> How about the following solution, which is based on a new :noweb-ref
>> header argument.
>> When expanding ``noweb'' style references the bodies of all code block
>> with /either/ a block name matching the reference name /or/ a :noweb-ref
>> header argument matching the reference name will be concatenated
>> together to form the replacement text.
>> By setting this header argument at the sub-tree or file level, simple
>> code block concatenation may be achieved.  For example, when tangling
>> the following Org-mode file, the bodies of code blocks will be
>> concatenated into the resulting pure code file.
> Hi,
> Your example is not completely clear. I noticed you didn't put any names
> for the source blocks that use the noweb-ref. Is it necessary not to
> name them,

The source code blocks may have names, as before all code block names
should be unique or the behavior may be undefined.

> or can one name them but their names will still have to be unique and
> are orthogonal to concatenation (i.e. they have names, but the
> concatenation is due to whatever the argument of noweb-ref is)?

The value of the :noweb-ref header argument supersedes the name of the
code block for noweb expansion.  To preserve existing semantics and to
avoid requiring the use of the :noweb-ref header argument in simple
cases, the code block name will be used to resolve noweb references in
blocks which do not have a :noweb-ref header argument.

> I think either way, this solution serves my purpose. My original
> suggestion was to have a header whose value would be "append" to allow
> for concatenation if the name matches a previous source block. It seems
> your solution above is the same except instead of looking at the name of
> the source block, it looks at the argument of noweb-ref.

Yup, happy this sounds like it should work for your original need.

> Overwriting is still not supported, but I don't know if that's all that
> important (I don't have an immediate need for it). And noweb by default
> did not have it either, so perhaps it's not needed for most tasks

This was my thinking.

> (OTOH, you may want to think about what the best solution is if later
> on you decide to add overwriting capability).

If someone finds a real need for overwriting code blocks, hopefully the
specifics of their need will point towards an implementation.

> Thanks. Hope to see this or something like it soon.

You welcome, hope this turns out to be helpful -- Eric

Eric Schulte

reply via email to

[Prev in Thread] Current Thread [Next in Thread]