On 12/26/2010 9:56 PM, Praki Prakash wrote:
Tim,
This approach is very interesting. My choice of mode for LP has always
been noweb-mode but it doesn't seem to work with my version of emacs
anymore. My current approach is to embed prose and clojure code in a
latex document and generate a .tex file with formatted clojure code
and .clj containing only clojure code. Needless to say, it is a hack
and I would like to see if I can adopt your approach.
Well, I'm something of a primitivist so I don't use modes in Emacs.
I know there is a noweb mode and a clojure mode and a latex mode but
I've never used any of them so I can't comment.
In the Knuth web approach (ala noweb) the chunk markup is not valid
latex. Therefore you need to run "weave" to extract valid latex.
I found this pointless so I wrote the latex environment macros to
wrap the code chunks. This means that the document you are writing
is always pure latex. So you might find it useful to use the chunk
environment and skip the "generate .tex file" step.
All that is left is to extract the clojure code. While writing the
code I have a REPL open so I can kill/yank changes directly. The
full build/test cycle uses the attached code to extract from the
literate document (which I call a "pamphlet").
However, I have a question on mapping of line numbers in clojure
stacktrace to its source. AFAIK, there is no support in clojure
compiler for #LINE directive. In my case, a code is always in one
location and I just replace latex lines with empty lines. How do you
address this issue?
I don't use the #LINE directive. I usually use a split screen
with lisp or clojure in a shell buffer (not a slime setup) and
my code in the other buffer. I've hand-checked the code in the
REPL before adding to or changing the document. After each change
I do a complete system rebuild/test cycle.
Thus, if it fails I know exactly what I broke and where I broke it.
It is broken at the last change, which is likely still in a buffer.
When it works, the code is already documented in latex and pdf (since
the build/test automatically regenerates the pdf).
I would like to see Clojure move toward literate programming and
have direct support for reading and compiling latex documents.
It is surprisingly efficient and effective. In my last 3 year
project I implemented over 60k lines of lisp and 6k pages of
documentation (with the embedded lisp code in literate form, of
course). When the "program was done", the "documentation was done".
In fact, that was true from the first day of the project and was
an invariant throughout. I highly recommend it.
Tim
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en