repl-reader accepts optional "read" argument
authorAndy Wingo <wingo@pobox.com>
Fri, 16 Oct 2009 11:30:52 +0000 (13:30 +0200)
committerAndy Wingo <wingo@pobox.com>
Fri, 16 Oct 2009 11:30:52 +0000 (13:30 +0200)
* module/ice-9/boot-9.scm (repl-reader): Accept an optional second
  argument, the reader to use. If it is given, use it instead of
  dereferencing the current-reader fluid.

* guile-readline/ice-9/readline.scm (activate-readline): Make our
  replacement definition of repl-reader compatible with boot-9.

guile-readline/ice-9/readline.scm
module/ice-9/boot-9.scm

index 4c852ee..4766e61 100644 (file)
@@ -1,6 +1,6 @@
 ;;;; readline.scm --- support functions for command-line editing
 ;;;;
-;;;;   Copyright (C) 1997, 1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
+;;;;   Copyright (C) 1997, 1999, 2000, 2001, 2002, 2006, 2009 Free Software Foundation, Inc.
 ;;;; 
 ;;;; This program is free software; you can redistribute it and/or modify
 ;;;; it under the terms of the GNU General Public License as published by
       (let ((repl-read-hook (lambda () (run-hook before-read-hook))))
        (set-current-input-port (readline-port))
        (set! repl-reader
-             (lambda (repl-prompt)
+             (lambda (repl-prompt . reader)
                (let ((outer-new-input-prompt new-input-prompt)
                      (outer-continuation-prompt continuation-prompt)
                      (outer-read-hook read-hook))
                        (set-buffered-input-continuation?! (readline-port) #f)
                        (set-readline-prompt! repl-prompt "... ")
                        (set-readline-read-hook! repl-read-hook))
-                     (lambda () ((or (fluid-ref current-reader) read)))
+                     (lambda () ((or (and (pair? reader) (car reader))
+                                      (fluid-ref current-reader)
+                                      read)))
                      (lambda ()
                        (set-readline-prompt! outer-new-input-prompt outer-continuation-prompt)
                        (set-readline-read-hook! outer-read-hook))))))
index c8881c6..6060f9f 100644 (file)
@@ -2705,11 +2705,14 @@ module '(ice-9 q) '(make-q q-length))}."
 ;;; The default repl-reader function.  We may override this if we've
 ;;; the readline library.
 (define repl-reader
-  (lambda (prompt)
+  (lambda (prompt . reader)
     (display (if (string? prompt) prompt (prompt)))
     (force-output)
     (run-hook before-read-hook)
-    ((or (fluid-ref current-reader) read) (current-input-port))))
+    ((or (and (pair? reader) (car reader))
+         (fluid-ref current-reader)
+         read)
+     (current-input-port))))
 
 (define (scm-style-repl)