I've managed to avoid blowing up my brain and created a noweb aspect for
the latex listings package, with accompanying lyx module.

As a result I don't need to use noweave, but I get noweave looking
output with the listings generated by the listings package with all it's
pretty printing.

The lyx module (called "newfangle") treats each \lstlisting as a noweb
style chunk, and uses the listing name as the chunk name.

It uses the noweb package macros merely to generate the chunk header and
navigation arrows to the previous and next chunk.

This avoids the need to use noweave for most uses, and removes for me
the need to use the literate lyx file format.

I'm still lacking is noweb markup of <<includes>>. I need to get
lstlistings to spot these...

Because Lyx doesn't show the listing name visually while editing it can
be very confusing to remember which listing has which name, so I've
added a Chunk style which sets the listing name. This will be persistent
until the next Chunk or the next explicitly named listing.

I prefix most of my listings with a highly visible chunk header.

The Chunk style pretty much just prefixes "name=" to it's text, and then
calls \lstset, but it does some magic to preserve the chunk name into
the listing.

I also have a newfangle awk script which works like notangle, but nicely
recognizes the latex that listings uses to pick out the code. The awk
script has less bugs that notangle, can manage -L output without
breaking the indents, and manage to suck C code into multi-line macros
without breaking.

I can now do literate programming with much more simplicity than before.

I hope that Lyx will be able to accept this work, and make literate
programming work more naturally.

I've been "are we nearly there yet" for the last 6 weeks, and I think my
answer is "yes" (the 3rd time around).

I'll post the code tomorrow, I need to run, but I didn't want anyone
working on my latex macro question now I solved it.

Sam
  • latex macro help... Sam Liddicott
    • newfangle - the new notangle and no more noweave Re: la... Sam Liddicott

Reply via email to