Instead of opening up a terminal to my virtual machine, I pop into Emacs and load this sprint’s note file, create a new header, and enter the shell and ruby commands in this text file.

What good is this? Unlike a traditional terminal, this allows me to log, document and execute each command.

For instance, here is a screen-shot of a section of my Emacs buffer:

As an old bear with very little brains, my prose can explain the background and purpose of each command. Clicking the hyperlink refreshes my memory of previous discoveries. A keychord executes the code block…

Yes. I execute the commands from within Emacs.

Hitting C-c C-c (Control-C twice) runs the code (based on the language). This example runs in the shell. The results are placed back into the file, which can be used by other code blocks (and many other options).

For instance, here is the first half of a section for downloading the GPG Keys from a repository (the URL is placed in a property that is shared among all code blocks in his section):

The Shell script block (in the center of the screen-shot) uses wget to download the HTML index file and parse and extract the key file URLs. We’ll have a Ruby script do that parsing, and since the script may be a bit hairy, we’ll define it in another code block.

One technique from literate programming is the idea that one code block can be inserted into another block (the reference is a name within double angle brackets, <<...>> ). Donald Knuth called this feature WEB. Since it can accidentally conflict with some languages (like Ruby), I have it off by default, but turn it on for this block with the noweb parameter.

Here is the Ruby script. Having it in a separate Ruby-specific code block allows me to turn on all the Ruby magic that Emacs can muster.

The last step is to take the URLs produced by the first script and feed them to another Shell script that will call wget to download each:

The key-list was the name of our original code block, as well as the name of its results. We assign that list of results to a variable, LIST that the shell script would access as $LIST .

This example demonstrated how literate programming can weave code and data through different languages.