Enhanced xmp code evaluation and annotation

Update

A new version of the xmp filter is available. It can also be used to generate unit test assertions given a working codebase needing to be tested.

Motivation

When I was writing Changes in Ruby 1.9, I had to evaluate
lots of small snippets under ruby 1.8 and 1.9, both to illustrate
the differences and to verify if some particular change described
in the changelogs still applied --- many were reverted later. I
wanted to do it all from vim and hence looked into
gotoken's xmp and the derived version found in rubygarden. The latter would fail for some examples,
forcing me to suspend vim, evaluate the snippet with ruby and ruby19,
and finally paste the results... Way too much work.

So I wrote a new xmp-style filter, hopefully more robust than the original one, and more featureful. This is what you get:

you can indicate which lines have to be annotated with the result value

the values for multiple runs of a given line are aggregated

new annotations corresponding to the warnings Ruby issued during parsing or execution

Needless to say, this is quite useful for ruby-talk postings, for instance.
Or for cheap and dirty debugging/testing, to verify what is going on inside a tight loop for instance. It takes but a keypress given the right keyboard mappings (see below).

As you can see, it uses popen3 so it won't work on win32. It wouldn't take much to make it use sockets for instance, reopening stderr and stdout in a BEGIN block. Christian Neukirchen, whom I showed an earlier version of the above script, came up with the idea of generating a script which collects the results and outputs the annotated sources itself. Unfortunately that won't work with syntactically incorrect inputs, forcing one to add a ruby -c phase, which is more than I felt like coding at the time. Alternatively, if a -e 'BEGIN{ }' parameter is passed to the Ruby interpreter, the line numbers in warnings and exceptions will be off by one (or more).