Hi James, The best thing that I've found for creating "living" documents is Org-mode's Babel <http://orgmode.org/worg/org-contrib/babel/>. It allows you to write code in a document which is executed when the document is compiled, with the source and/or the results getting inserted into the document (which can be transformed to LaTeX). If your code generates images, you can even have them inserted, too (likely not what you're looking for, but still a cool feature!) However, there is one big caveat: Org-mode is an Emacs mode, so not only would you need to use Emacs, but so would anyone compiling the document. I could understand if this is too much of a barrier of entry for your liking.
Another suggestion which seems a bit more in line with your desires would be to use a macro like so: (define counter (make-parameter 1)) (define-syntax repl-print (syntax-rules () ((_ form) (let ((result form)) (printf "#;~s> ~s~%" (counter) (quote form)) (unless (equal? result (void)) (print result)) (counter (add1 (counter))))))) Which can then be used like so: (repl-print (+ 5 1)) (repl-print (define (f x) (+ x 1))) (repl-print (f 5)) with e.g. something like `csi -script foo.scm > foo.out` to produce almost the same output as your example. One issue this macro has is that it doesn't know about whitespace, so you're kind of limited to one line. You could work around that by using a pretty printer with a bit of padding magic, but it still won't give you "proper" Scheme indentation. Still, most REPL examples should be one-liners, I'd think (and hope for your sake ;) ) Whatever you choose to do, good luck with your project! I look forward to seeing the result :) Alex On Sat, Jan 23, 2016 at 12:51 PM Hefferon, James S. <jheffe...@smcvt.edu> wrote: > > Thank you for the "script" suggestion. I apologize but I don't understand > it. > > I'm looking for a way to automatically capture an interactive session, and > drop > it to a file, without cutting and pasting from a terminal or an editor. > When I use > LaTeX to compile the book, I'd like that as part of the compilation it runs > Chicken's csi and captures the session, so that session can be > brought into the document. (My past experience with cutting and pasting > is that as > the document changes the code samples get out of sync. In addition, I'd > like that > if a person gets the doc off my github account and they compile the doc > then they > know their setup matches their doc.) > > That is, I'd like to feed this to csi, and then grab the transcript. > > #;1> (+ 5 1) > 6 > #;2> (define (f x) > (+ x 1)) > #;3> (f 5) > 6 > > I can get LaTeX to run programs, for example to call "csi -script foo.scm > > foo.out". But > I'm not sure if it is possible to grab the REPL without an Expect-type > situation. > > I understand "script" it will give me a single output, and not show the > REPL at all. > Am I missing the point (probably)? > > Thank you, > Jim > _______________________________________________ > Chicken-users mailing list > Chicken-users@nongnu.org > https://lists.nongnu.org/mailman/listinfo/chicken-users >
_______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users