From: Andy Wingo Date: Fri, 16 Oct 2009 11:30:52 +0000 (+0200) Subject: repl-reader accepts optional "read" argument X-Git-Url: https://git.hcoop.net/bpt/guile.git/commitdiff_plain/a58b7fbb7eb80bdbc0af9aee86a5ac12b9cfeef3 repl-reader accepts optional "read" argument * 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. --- diff --git a/guile-readline/ice-9/readline.scm b/guile-readline/ice-9/readline.scm index 4c852eec1..4766e619e 100644 --- a/guile-readline/ice-9/readline.scm +++ b/guile-readline/ice-9/readline.scm @@ -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 @@ -208,7 +208,7 @@ (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)) @@ -217,7 +217,9 @@ (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)))))) diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index c8881c68f..6060f9ff1 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -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)