diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-11-09 21:52:56 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-11-09 21:52:56 +0100 |
commit | 27916d2da2e43f231daff12249b19701f5a27b4f (patch) | |
tree | 8425627764ba5a195a25665da5a2c62ce2f221bd /scheme/racket/geiser/user.rkt | |
parent | d830e14a4010284b4085d9942bfd856b0360d793 (diff) | |
parent | f2bf4b2cda05fe8c32ee74ce3b5cce743d81de61 (diff) | |
download | geiser-guile-27916d2da2e43f231daff12249b19701f5a27b4f.tar.gz geiser-guile-27916d2da2e43f231daff12249b19701f5a27b4f.tar.bz2 |
Merge branch 'master' into guile-meta
Conflicts:
elisp/geiser-guile.el
Diffstat (limited to 'scheme/racket/geiser/user.rkt')
-rw-r--r-- | scheme/racket/geiser/user.rkt | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/scheme/racket/geiser/user.rkt b/scheme/racket/geiser/user.rkt index 20f8a00..37763b9 100644 --- a/scheme/racket/geiser/user.rkt +++ b/scheme/racket/geiser/user.rkt @@ -11,9 +11,10 @@ #lang racket/base -(provide enter!) +(provide init-geiser-repl run-geiser-repl enter!) -(require geiser/main geiser/enter geiser/eval (for-syntax racket/base)) +(require (for-syntax racket/base) + geiser/main geiser/enter geiser/eval geiser/modules) (define top-namespace (current-namespace)) @@ -29,37 +30,53 @@ mod)))) (define orig-loader (current-load/use-compiled)) +(define geiser-loader (module-loader orig-loader)) -(define orig-reader (current-prompt-read)) +(define geiser-send-null (make-parameter #f)) (define (geiser-eval) (define geiser-main (module->namespace 'geiser/main)) - (let* ((mod (read)) - (lang (read)) - (form (read))) + (geiser-send-null #t) + (let* ([mod (read)] + [lang (read)] + [form (read)]) (datum->syntax #f (list 'quote - (cond ((equal? form '(unquote apply)) - (let* ((proc (eval (read) geiser-main)) - (args (read))) - ((geiser:eval lang) `(,proc ,@args) mod))) - (else ((geiser:eval lang) form mod))))))) + (cond [(equal? form '(unquote apply)) + (let* ([proc (eval (read) geiser-main)] + [args (read)]) + ((geiser:eval lang) `(,proc ,@args) mod))] + [else ((geiser:eval lang) form mod)]))))) (define (geiser-read) - (let ((form (orig-reader))) + (if (geiser-send-null) + (begin (geiser-send-null #f) + (write-char #\nul)) + (printf "racket@~a> " (namespace->module-name (current-namespace)))) + (flush-output) + (let* ([in (current-input-port)] + [form ((current-read-interaction) (object-name in) in)]) (syntax-case form () - ((uq cmd) (eq? 'unquote (syntax-e #'uq)) + [(uq cmd) (eq? 'unquote (syntax-e #'uq)) (case (syntax-e #'cmd) ((enter) (enter! (read) #'cmd)) ((geiser-eval) (geiser-eval)) ((geiser-no-values) (datum->syntax #f (void))) - (else form))) - (_ form)))) + (else form))] + [_ form]))) -(define (init) +(define geiser-prompt-read (make-repl-reader geiser-read)) + +(define (init-geiser-repl) (compile-enforce-module-constants #f) - (current-load/use-compiled (module-loader orig-loader)) - (current-prompt-read - (compose (make-repl-reader geiser-read) current-namespace))) + (current-load/use-compiled geiser-loader) + (current-prompt-read geiser-prompt-read)) -(init) +(define (run-geiser-repl in out enforce-module-constants) + (parameterize [(compile-enforce-module-constants enforce-module-constants) + (current-input-port in) + (current-output-port out) + (current-error-port out) + (current-load/use-compiled geiser-loader) + (current-prompt-read geiser-prompt-read)] + (read-eval-print-loop))) |