diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-11-08 03:39:36 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-11-08 03:39:36 +0100 |
commit | 6a197dae0735eb92f66ee98a8ca4137eac7649ee (patch) | |
tree | 28fd30b1c68748fb72943e63f8eff3f9a56038a7 /scheme | |
parent | a73fdcb10bb6144d7befbc4c553102c9816e86c9 (diff) | |
download | geiser-chez-6a197dae0735eb92f66ee98a8ca4137eac7649ee.tar.gz geiser-chez-6a197dae0735eb92f66ee98a8ca4137eac7649ee.tar.bz2 |
Racket: use EOT token for internal communications
Diffstat (limited to 'scheme')
-rw-r--r-- | scheme/racket/geiser/eval.rkt | 16 | ||||
-rw-r--r-- | scheme/racket/geiser/modules.rkt | 4 | ||||
-rw-r--r-- | scheme/racket/geiser/user.rkt | 32 |
3 files changed, 30 insertions, 22 deletions
diff --git a/scheme/racket/geiser/eval.rkt b/scheme/racket/geiser/eval.rkt index f66f149..78db857 100644 --- a/scheme/racket/geiser/eval.rkt +++ b/scheme/racket/geiser/eval.rkt @@ -17,15 +17,13 @@ compile-file macroexpand make-repl-reader) + (require geiser/enter geiser/modules geiser/autodoc) (require errortrace/errortrace-lib) (define last-result (void)) -(define namespace->module-name - (compose module-path-name->name namespace->module-path-name)) - (define last-namespace (make-parameter (current-namespace))) (define (exn-key e) @@ -59,8 +57,7 @@ (lambda () (update-signature-cache spec form) (eval form (module-spec->namespace spec lang))))) - (newline) - (flush-output)) + (newline)) (define compile-in eval-in) @@ -76,10 +73,9 @@ (lambda () (pretty-print (syntax->datum ((if all expand expand-once) form))))))) -(define (make-repl-reader builtin-reader) - (lambda (ns) - (last-namespace ns) - (printf "racket@~a" (namespace->module-name ns)) - (builtin-reader))) +(define (make-repl-reader reader) + (lambda () + (last-namespace (current-namespace)) + (reader))) ;;; eval.rkt ends here diff --git a/scheme/racket/geiser/modules.rkt b/scheme/racket/geiser/modules.rkt index 5c6ba1f..0591a92 100644 --- a/scheme/racket/geiser/modules.rkt +++ b/scheme/racket/geiser/modules.rkt @@ -14,6 +14,7 @@ (provide load-module ensure-module-spec module-spec->namespace + namespace->module-name namespace->module-path-name module-path-name->name module-spec->path-name @@ -79,6 +80,9 @@ [(symbol? path) (symbol->string path)] [else ""])) +(define namespace->module-name + (compose module-path-name->name namespace->module-path-name)) + (define (skippable-dir? path) (call-with-values (lambda () (split-path path)) (lambda (_ basename __) diff --git a/scheme/racket/geiser/user.rkt b/scheme/racket/geiser/user.rkt index e00e306..e615400 100644 --- a/scheme/racket/geiser/user.rkt +++ b/scheme/racket/geiser/user.rkt @@ -13,7 +13,8 @@ (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)) @@ -31,7 +32,7 @@ (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)) @@ -47,18 +48,25 @@ (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)) - (case (syntax-e #'cmd) - ((enter) (enter! (read) #'cmd)) - ((geiser-eval) (geiser-eval)) - ((geiser-no-values) (datum->syntax #f (void))) - (else form))) - (_ form)))) + [(uq cmd) (eq? 'unquote (syntax-e #'uq)) + (begin + (geiser-send-null #t) + (case (syntax-e #'cmd) + ((enter) (enter! (read) #'cmd)) + ((geiser-eval) (geiser-eval)) + ((geiser-no-values) (datum->syntax #f (void))) + (else form)))] + [_ form]))) -(define geiser-prompt-read - (compose (make-repl-reader geiser-read) current-namespace)) +(define geiser-prompt-read (make-repl-reader geiser-read)) (define (init-geiser-repl) (compile-enforce-module-constants #f) |