[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] Literate Programming in TeXmacs?

From: Felix Breuer
Subject: Re: [Texmacs-dev] Literate Programming in TeXmacs?
Date: Mon, 21 May 2007 22:03:36 +0200

Hello again!

One of the unique features of TeXmacs are its session plugins. I have
frequently have found myself wanting to "rerun" a sequence of
computations in a session with some slight modifications. In this
fashion an interactive session can even turn step by step into a
program. Thus, it is a natural idea to integrate a potential LP feature
of TeXmacs with its session features.

A simple implementation that serves both purposes might look as
follows. Suppose snippets of code in the document are wrapped in an
environment like


where label is an arbitrary string that marks which snippets belong
together and body is an arbitrary TeXmacs tree that is "the code". Now
the LP implementation might have a function

   (label-to-code label filter)

at its core that does:

  * collect all nodes in the document that are of type "lp-code" and
    have label _label_ as their first argument
  * apply the export filter _filter_ to the second arguments of each of
    the nodes in turn
  * concatenate the resulting list of strings and return it.

The resulting string could then either be written to a file or fed to a
session line by line.

Some comments:

* This bare-bones solution should be really simple to implement.
* One can add custom source code formatting and generation methods
  simply by writing a style file and accompanying export filter. This
  - make use of standard TeXmacs mechanisms
  - tie in with the use of filters to store entire TeXmacs documents as
    ASCII source code files as David and I had envisioned
  - allow one to copy-and-paste fancy formatted code from TeXmacs into
    a text editor.
* Instead of using a fixed environment name like "lp-code" and
  plain-text labels, one should probably use DRD properties and loci (I
  just have no idea how these work).
* One could add facilities to reorder code chunks during code
  generation later on.

So much for now. Comments are welcome!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]