emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: Achim Gratz <Stromeko@nexgo.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: Literate Programming - Continue a Source Block?
Date: Wed, 15 Jun 2011 21:54:20 -0700	[thread overview]
Message-ID: <87mxhicr5v.fsf@gmail.com> (raw)
In-Reply-To: 87pqmeaj3p.fsf@Rainer.invalid

[-- Attachment #1: Type: text/plain, Size: 2336 bytes --]

Achim Gratz <Stromeko@nexgo.de> writes:

> Eric Schulte <schulte.eric@gmail.com> writes:
>> Does anyone on this list know the noweb system well enough to specify
>> its behavior in this regard, and to describe what functional changes
>> would be required to bring Babel into line with noweb behavior?
>
> Far from knowing it well, but the basics are, well basic:
>
> Documentation text is started via '@', code chunks are defined via
> '<<chunk_name>>=' and a given chunk can be extended by '<<chunk_name>>='
> with the same name again, which allows to intermingle documentation and
> definition in a linear fashion.  Code chunk references are just
> '<<chunk_name>>' without the equal sign and can be used non-linearly.
> For comparison with Babel the noweb Hackers Guide is probably a good
> source since it describes the pipeline representation which is used by
> the tools (and should maybe be emulated by the Babel backend).
>
> http://www.cs.tufts.edu/~nr/noweb/guide.html
>

Hi Achim,

Thanks for sending along this reference.  That combined with the related
"Literate Programming Simplified" [1] serve as a very interesting
introduction to Noweb.  I have not studied noweb previously and I am
impressed by the simplicity of the pipelined filter-based design.

Noweb and Babel are certainly very different beasts.  Noweb achieves
sparse simplicity allowing use with a variety of tools while Babel lives
inside the very rich environment of Org-mode documents.  Noweb enables
literate programming LP while babel is a reproducible research tool
which also provides support for LP.

It seems that lifting a solution whole-piece from noweb will not make
sense, as noweb does not have a need for unique code block names in the
same way as babel.

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: append.org --]
[-- Type: text/x-org, Size: 472 bytes --]

#+begin_src sh :tangle yes :noweb yes :shebang #!/bin/sh
  <<fullest-disk>>
#+end_src

* the mount point of the fullest disk
  :PROPERTIES:
  :noweb-ref: fullest-disk
  :END:

** query all mounted disks
#+begin_src sh
  df \
#+end_src

** strip the header row
#+begin_src sh
  |sed '1d' \
#+end_src

** sort by the percent full
#+begin_src sh
  |awk '{print $5 " " $6}'|sort -n |tail -1 \
#+end_src

** extract the mount point
#+begin_src sh
  |awk '{print $2}'
#+end_src

[-- Attachment #3: Type: text/plain, Size: 191 bytes --]


This should provide feature-parity with noweb, and satisfy most LP needs.

Best -- Eric

Footnotes: 
[1]  www.cs.tufts.edu/~nr/pubs/lpsimp.pdf

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

  reply	other threads:[~2011-06-16  4:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-08  5:47 Literate Programming - Continue a Source Block? Neeum Zawan
2011-06-08  7:34 ` Sebastien Vauban
2011-06-08 15:20   ` Neeum Zawan
2011-06-08 19:40     ` Eric Schulte
2011-06-08 21:20       ` Neeum Zawan
2011-06-10  4:55         ` Avdi Grimm
2011-06-10 19:09         ` Eric Schulte
2011-06-10 19:27           ` Achim Gratz
2011-06-10 20:00             ` Eric Schulte
2011-06-12  8:32               ` Achim Gratz
2011-06-13 22:04                 ` Eric Schulte
2011-06-14 20:48                   ` Achim Gratz
2011-06-15 17:23                     ` Eric Schulte
2011-06-15 21:19                       ` Achim Gratz
2011-06-16  4:54                         ` Eric Schulte [this message]
2011-06-16  2:35                       ` Neeum Zawan
2011-06-11  1:02             ` Neeum Zawan
2011-06-11  0:44           ` Neeum Zawan
2011-06-11 20:08             ` Eric Schulte
2011-06-12  5:36               ` Neeum Zawan
2011-06-13 21:57                 ` Eric Schulte
2011-06-15  5:17                   ` Neeum Zawan
2011-06-15 17:27                     ` Eric Schulte
2011-06-15 19:37                       ` Neeum Zawan
2011-06-16  2:26                         ` Eric Schulte
2011-06-17  4:30                           ` Neeum Zawan
2011-06-17  4:39                             ` Eric Schulte
2011-06-17  7:00                               ` Sebastien Vauban
2011-06-19 23:38                                 ` Neeum Zawan
2011-06-16 10:14     ` Olaf.Hamann

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=87mxhicr5v.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=Stromeko@nexgo.de \
    --cc=emacs-orgmode@gnu.org \
    /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).