summaryrefslogtreecommitdiff
path: root/module/system/repl/repl.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-11-18 14:32:53 +0100
committerAndy Wingo <wingo@pobox.com>2010-11-18 14:32:53 +0100
commitc372cd74fdc5de5b3ee3299b77a7881e271c649c (patch)
tree1892c7c079a02554be31ef10c5075f3a4026bbc0 /module/system/repl/repl.scm
parent9b5fcde6f9488e9836b090f8da292bf3f2642ca6 (diff)
downloadguile-c372cd74fdc5de5b3ee3299b77a7881e271c649c.tar.gz
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.
Diffstat (limited to 'module/system/repl/repl.scm')
-rw-r--r--module/system/repl/repl.scm27
1 files changed, 13 insertions, 14 deletions
diff --git a/module/system/repl/repl.scm b/module/system/repl/repl.scm
index 7847b50e9..b135dbb71 100644
--- a/module/system/repl/repl.scm
+++ b/module/system/repl/repl.scm
@@ -63,20 +63,19 @@
(define meta-command-token (cons 'meta 'command))
(define (meta-reader read env)
- (lambda read-args
- (let ((port (if (pair? read-args) (car read-args) (current-input-port))))
- (with-input-from-port port
- (lambda ()
- (let ((ch (next-char #t)))
- (cond ((eof-object? ch)
- ;; EOF objects are not buffered. It's quite possible
- ;; to peek an EOF then read something else. It's
- ;; strange but it's how it works.
- ch)
- ((eqv? ch #\,)
- (read-char port)
- meta-command-token)
- (else (read port env)))))))))
+ (lambda* (#:optional (port (current-input-port)))
+ (with-input-from-port port
+ (lambda ()
+ (let ((ch (next-char #t)))
+ (cond ((eof-object? ch)
+ ;; EOF objects are not buffered. It's quite possible
+ ;; to peek an EOF then read something else. It's
+ ;; strange but it's how it works.
+ ch)
+ ((eqv? ch #\,)
+ (read-char port)
+ meta-command-token)
+ (else (read port env))))))))
;; repl-reader is a function defined in boot-9.scm, and is replaced by
;; something else if readline has been activated. much of this hoopla is