unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Newbie question - How do I get a full transcript?
@ 2002-11-21 20:00 Tim Halliday
  2002-11-21 20:52 ` Neil Jerram
  2002-11-21 21:34 ` Brett Viren
  0 siblings, 2 replies; 4+ messages in thread
From: Tim Halliday @ 2002-11-21 20:00 UTC (permalink / raw)



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

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

Is there a better way to go about this?

Thanks

-- 

Tim Halliday
t-halliday@ti.com
214.480.1399



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Newbie question - How do I get a full transcript?
  2002-11-21 20:00 Newbie question - How do I get a full transcript? Tim Halliday
@ 2002-11-21 20:52 ` Neil Jerram
  2002-11-21 22:37   ` Tim Halliday
  2002-11-21 21:34 ` Brett Viren
  1 sibling, 1 reply; 4+ messages in thread
From: Neil Jerram @ 2002-11-21 20:52 UTC (permalink / raw)
  Cc: guile-user

>>>>> "Tim" == Tim Halliday <t-halliday@ti.com> 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



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Newbie question - How do I get a full transcript?
  2002-11-21 20:00 Newbie question - How do I get a full transcript? Tim Halliday
  2002-11-21 20:52 ` Neil Jerram
@ 2002-11-21 21:34 ` Brett Viren
  1 sibling, 0 replies; 4+ messages in thread
From: Brett Viren @ 2002-11-21 21:34 UTC (permalink / raw)
  Cc: guile-user

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

Does "screen" do this?

-Brett.



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Newbie question - How do I get a full transcript?
  2002-11-21 20:52 ` Neil Jerram
@ 2002-11-21 22:37   ` Tim Halliday
  0 siblings, 0 replies; 4+ messages in thread
From: Tim Halliday @ 2002-11-21 22:37 UTC (permalink / raw)



Neil,

Thanks. You suggestion pointed me down a fruitful path. I'm not using
readline at the moment, so I can get away with the following.

-tim



(define (fork-out-port stdPort transPort )
   (make-soft-port
     (vector
       (lambda (c)
          ( write c stdPort )
          ( write c transPort )
          ( force-output transPort ) )
       (lambda (s)
          ( display s stdPort )
          ( display s transPort )
          ( force-output transPort ) )
       (lambda ()
          ( force-output stdPort )
          ( force-output transPort ) )
       (lambda () #f )
       (lambda ()
          ( close-port stdPort )
          ( close-port transPort ) )
     )
     "w"
))

(define (fork-in-port stdPort transPort )
   (make-soft-port
     (vector
       (lambda (c) #f)
       (lambda (s) #f)
       (lambda () #f)
       (lambda ()
         (define c (read-char stdPort ) )
         (display c transPort )
         c )
       (lambda ()
          ( close-port stdPort )
          ( close-port transPort ) )
     )
     "rw"
))

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





Neil Jerram wrote:
>>>>>>"Tim" == Tim Halliday <t-halliday@ti.com> 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
> 
> 


-- 

Tim Halliday
t-halliday@ti.com
214.480.1399



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-11-21 22:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-21 20:00 Newbie question - How do I get a full transcript? Tim Halliday
2002-11-21 20:52 ` Neil Jerram
2002-11-21 22:37   ` Tim Halliday
2002-11-21 21:34 ` Brett Viren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).