diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2011-02-27 13:14:30 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2011-02-27 13:14:30 +0100 |
commit | 68a4e69aca1f8a84330def1ee24b2da6243419c0 (patch) | |
tree | 5d44f050064058f7830677ab38d58a0da00d5495 /scheme/racket/geiser/user.rkt | |
parent | 8eac2e737ac4f7563c944f4cfec9e8075d307d78 (diff) | |
download | geiser-chez-68a4e69aca1f8a84330def1ee24b2da6243419c0.tar.gz geiser-chez-68a4e69aca1f8a84330def1ee24b2da6243419c0.tar.bz2 |
Racket: no errors ,entering an R5RS module
The catch here is that one cannot use #%variable-reference inside an
R5RS module, and, as a consequence, namespace->module-path-name was
failing badly. The solution is to take note of the module name being
entered before hand, and use that name in case of error (we could
actually use that name always, but then cheaters using Racket's enter!
would see an inconsistent name (which probably they deserve)).
Diffstat (limited to 'scheme/racket/geiser/user.rkt')
-rw-r--r-- | scheme/racket/geiser/user.rkt | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/scheme/racket/geiser/user.rkt b/scheme/racket/geiser/user.rkt index 72aa48a..69a5df7 100644 --- a/scheme/racket/geiser/user.rkt +++ b/scheme/racket/geiser/user.rkt @@ -22,13 +22,23 @@ geiser/modules) (define top-namespace (current-namespace)) +(define last-entered (make-parameter "")) + +(define (do-enter mod name) + (enter-module mod) + (current-namespace (module->namespace mod)) + (last-entered name)) (define (enter! mod stx) - (cond [(not mod) (current-namespace top-namespace)] - [(module-path? mod) - (enter-module mod) - (current-namespace (module->namespace mod))] - [(path-string? mod) (enter! `(file ,mod) stx)] + (cond [(not mod) + (current-namespace top-namespace) + (last-entered "")] + [(symbol? mod) (do-enter mod (symbol->string mod))] + [(and (list? mod) + (= 2 (length mod)) + (eq? 'file (car mod)) + (path-string? (cadr mod))) (do-enter mod (cadr mod))] + [(path-string? mod) (do-enter `(file ,mod) mod)] [else (raise-syntax-error #f "not a valid module path, and not #f" @@ -68,7 +78,8 @@ (define geiser-prompt (lambda () - (printf "racket@~a> " (namespace->module-name (current-namespace))))) + (printf "racket@~a> " + (namespace->module-name (current-namespace) (last-entered))))) (define (geiser-prompt-read prompt) (make-repl-reader (geiser-read prompt))) |