guile-user
[Top][All Lists]
Advanced

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

Re: Newbie question - How do I get a full transcript?


From: Neil Jerram
Subject: Re: Newbie question - How do I get a full transcript?
Date: 21 Nov 2002 20:52:16 +0000
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

>>>>> "Tim" == Tim Halliday <address@hidden> writes:

    Tim> I've got a C application which I've bound Guile into. I want
    Tim> to generate a complete transcript of everything that the user
    Tim> enters, or Guile displays during the session.

    Tim> I've tried specifying hooks for before-print-hook and
    Tim> before-eval-hook, but that doesn't seem to get me everything
    Tim> like Guile generated error messages.

    Tim> Is there a better way to go about this?

Interesting question.  I don't think there's any simple way.  For a
transcript of output you can create a new output that acts like `tee':

(define (fork-port . ports)
  (make-soft-port 
    (vector
      (lambda (c)
        (for-each (lambda (port)
                    (write c port))
                  ports))
      (lambda (s)
        (for-each (lambda (port)
                    (display s port))
                  ports))
      (lambda ()
        (for-each force-output ports))
      #f
      (lambda ()
        (for-each close-port ports)))
    "w"))

(let ((transcript (open-output-file "transcript")))
  (set-current-output-port (fork-port (current-output-port) transcript))
  (set-current-error-port (fork-port (current-error-port) transcript)))

Input is trickier because of readline.

        Neil





reply via email to

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