summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scheme/racket/geiser/user.rkt24
1 files changed, 20 insertions, 4 deletions
diff --git a/scheme/racket/geiser/user.rkt b/scheme/racket/geiser/user.rkt
index b476de4..272fcd9 100644
--- a/scheme/racket/geiser/user.rkt
+++ b/scheme/racket/geiser/user.rkt
@@ -13,7 +13,7 @@
(provide enter!)
-(require geiser/enter geiser/eval (for-syntax racket/base))
+(require geiser/main geiser/enter geiser/eval (for-syntax racket/base))
(define top-namespace (current-namespace))
@@ -32,12 +32,28 @@
(define orig-reader (current-prompt-read))
+(define (geiser-eval)
+ (define geiser-main (module->namespace 'geiser/main))
+ (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)))))))
+
(define (geiser-read)
(let ((form (orig-reader)))
(syntax-case form ()
- ((uq cmd) (and (eq? 'unquote (syntax-e #'uq))
- (eq? 'enter (syntax-e #'cmd)))
- (enter! (read) #'cmd))
+ ((uq cmd) (eq? 'unquote (syntax-e #'uq))
+ (case (syntax-e #'cmd)
+ ((enter) (enter! (read) #'cmd))
+ ((eval) (geiser-eval))
+ ((no-values) (datum->syntax #f (void)))
+ (else form)))
(_ form))))
(define (init)