diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2013-06-10 00:06:55 +0200 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2013-06-10 00:06:55 +0200 |
commit | 7b1a1d046059eb2ce68ea02706a0e7494c39684f (patch) | |
tree | 8a72cf5b83d913cc29802ecc4d1083b5c8386423 /scheme/racket/geiser/user.rkt | |
parent | bba166c3ccb136fa8321ad9acc9cfd48a5fed357 (diff) | |
download | geiser-guile-7b1a1d046059eb2ce68ea02706a0e7494c39684f.tar.gz geiser-guile-7b1a1d046059eb2ce68ea02706a0e7494c39684f.tar.bz2 |
racket: new ,geiser-load command in REPL
... and used also internally for C-c C-k, although it doesn't yet work
as well as i wanted when it comes to load modules. The reason is
probably in geiser/enter, where we don't record modification times per
submodule but per path, which is not correct in the presence of submodules.
Diffstat (limited to 'scheme/racket/geiser/user.rkt')
-rw-r--r-- | scheme/racket/geiser/user.rkt | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/scheme/racket/geiser/user.rkt b/scheme/racket/geiser/user.rkt index 5ce003d..cd3fea6 100644 --- a/scheme/racket/geiser/user.rkt +++ b/scheme/racket/geiser/user.rkt @@ -48,6 +48,9 @@ [(symbol? parent) mod] [else #f])))) +(define (module-error stx mod) + (raise-syntax-error #f "Invalid module path" stx mod)) + (define (enter! mod stx) (cond [(not mod) (current-namespace top-namespace) @@ -56,7 +59,7 @@ [(path-string? mod) (do-enter `(file ,mod) mod)] [(file-mod? mod) (do-enter mod (cadr mod))] [(submod-path mod) => (lambda (m) (do-enter m m))] - [else (raise-syntax-error #f "Invalid module path" stx mod)])) + [else (module-error stx mod)])) (define orig-loader (current-load/use-compiled)) (define geiser-loader (module-loader orig-loader)) @@ -66,15 +69,25 @@ (define (eval-here form) (eval form geiser-main)) (let* ([mod (read)] [lang (read)] - [form (read)]) - (datum->syntax #f - (list 'quote - (cond [(equal? form '(unquote apply)) - (let* ([proc (eval-here (read))] - [args (map eval-here (read))] - [ev (lambda () (apply proc args))]) - (eval-in `(,ev) mod lang))] - [else ((geiser:eval lang) form mod)]))))) + [form (read)] + [res (cond [(equal? form '(unquote apply)) + (let* ([proc (eval-here (read))] + [args (map eval-here (read))] + [ev (lambda () (apply proc args))]) + (eval-in `(,ev) mod lang))] + [else ((geiser:eval lang) form mod)])]) + (datum->syntax #f (list 'quote res)))) + +(define (geiser-load stx) + (let* ([mod (read)] + [res (call-with-result + (lambda () + (enter-module (cond [(file-mod? mod) mod] + [(path-string? mod) `(file ,mod)] + [(submod-path mod)] + [else (module-error stx mod)])) + (void)))]) + (datum->syntax stx (list 'quote res)))) (define ((geiser-read prompt)) (prompt) @@ -88,6 +101,7 @@ [(start-geiser) (datum->syntax #f `(list 'port ,(start-geiser)))] [(enter) (enter! (read) #'cmd)] [(geiser-eval) (geiser-eval)] + [(geiser-load) (geiser-load #'cmd)] [(geiser-no-values) (datum->syntax #f (void))] [(add-to-load-path) (add-to-load-path (read))] [(set-image-cache) (image-cache (read))] |