From d89131b0ff58fb6d8d12fa0404f2b0d26e964d72 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sat, 30 Oct 2010 04:54:59 +0200 Subject: Racket: new meta-commands: ,eval ,apply ,no-values --- scheme/racket/geiser/user.rkt | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'scheme/racket') 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) -- cgit v1.2.3