From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Literate Programming - Continue a Source Block? Date: Wed, 15 Jun 2011 21:54:20 -0700 Message-ID: <87mxhicr5v.fsf@gmail.com> References: <87pqmokh6d.fsf@fester.com> <80k4cw22uf.fsf@somewhere.org> <87fwnkjqoh.fsf@fester.com> <87mxhsnmcf.fsf@gmail.com> <877h8wj9za.fsf@fester.com> <877h8tv6yh.fsf@gmail.com> <87oc25mqqq.fsf@Rainer.invalid> <8739jhv4ma.fsf@gmail.com> <87mxhn8n7i.fsf@Rainer.invalid> <87tybtidzy.fsf@gmail.com> <87ei2wgmvw.fsf@Rainer.invalid> <877h8nuhr3.fsf@gmail.com> <87pqmeaj3p.fsf@Rainer.invalid> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:59462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QX4b7-0002tf-Ks for emacs-orgmode@gnu.org; Thu, 16 Jun 2011 00:54:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QX4b6-0000b2-BZ for emacs-orgmode@gnu.org; Thu, 16 Jun 2011 00:54:29 -0400 Received: from mail-pw0-f41.google.com ([209.85.160.41]:54698) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QX4b6-0000ay-4n for emacs-orgmode@gnu.org; Thu, 16 Jun 2011 00:54:28 -0400 Received: by pwi12 with SMTP id 12so503418pwi.0 for ; Wed, 15 Jun 2011 21:54:26 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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: Achim Gratz Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Achim Gratz writes: > Eric Schulte 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 > '<>=' and a given chunk can be extended by '<>=' > with the same name again, which allows to intermingle documentation and > definition in a linear fashion. Code chunk references are just > '<>' 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. --=-=-= Content-Type: text/x-org Content-Disposition: inline; filename=append.org #+begin_src sh :tangle yes :noweb yes :shebang #!/bin/sh <> #+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 --=-=-= Content-Type: text/plain 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/ --=-=-=--