1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 17:20:29 +02:00

repl read/write using current ports, not captured ports

Fixes bug in repl meta-commands after activating readline, which changes
the current input port.

* module/system/repl/common.scm (<repl>): Remove inport and outport
  fields.
  (make-repl): Adapt.
  (repl-read, repl-print): Just read and write to the current ports.

* module/system/repl/repl.scm (meta-reader): Meta-read from the current
  input port.

* module/system/repl/command.scm (read-command, define-meta-command):
  Read from the current input port.
This commit is contained in:
Andy Wingo 2010-11-18 14:32:53 +01:00
parent 9b5fcde6f9
commit c372cd74fd
3 changed files with 27 additions and 35 deletions

View file

@ -136,7 +136,7 @@
(define (read-command repl)
(catch #t
(lambda () (read (repl-inport repl)))
(lambda () (read))
(lambda (key . args)
(pmatch args
((,subr ,msg ,args . ,rest)
@ -148,11 +148,6 @@
(force-output)
*unspecified*)))
(define read-line
(let ((orig-read-line read-line))
(lambda (repl)
(orig-read-line (repl-inport repl)))))
(define (meta-command repl)
(let ((command (read-command repl)))
(cond
@ -183,19 +178,19 @@
(% (let* ((expression0
(catch #t
(lambda ()
(repl-reader ""
(lambda* (#:optional (port (repl-inport repl)))
((language-reader (repl-language repl))
port (current-module)))))
(repl-reader
""
(lambda* (#:optional (port (current-input-port)))
((language-reader (repl-language repl))
port (current-module)))))
(lambda (k . args)
(handle-read-error 'expression0 k args))))
...)
(apply (lambda* datums
(with-output-to-port (repl-outport repl)
(lambda () b0 b1 ...)))
b0 b1 ...)
(catch #t
(lambda ()
(let ((port (open-input-string (read-line repl))))
(let ((port (open-input-string (read-line))))
(let lp ((out '()))
(let ((x (read port)))
(if (eof-object? x)