summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elisp/geiser-racket.el6
-rw-r--r--scheme/racket/geiser/user.rkt55
2 files changed, 27 insertions, 34 deletions
diff --git a/elisp/geiser-racket.el b/elisp/geiser-racket.el
index 28c576a..f38a4e9 100644
--- a/elisp/geiser-racket.el
+++ b/elisp/geiser-racket.el
@@ -132,9 +132,9 @@ This function uses `geiser-racket-init-file' if it exists."
(defun geiser-racket--enter-command (module)
(when (stringp module)
- (cond ((zerop (length module)) "(enter! #f)")
- ((file-name-absolute-p module) (format "(enter! (file %S))" module))
- (t (format "(enter! %s)" module)))))
+ (cond ((zerop (length module)) ",enter #f")
+ ((file-name-absolute-p module) (format ",enter (file %S)" module))
+ (t (format ",enter %s" module)))))
(defun geiser-racket--import-command (module)
(and (stringp module)
diff --git a/scheme/racket/geiser/user.rkt b/scheme/racket/geiser/user.rkt
index 33b8186..b476de4 100644
--- a/scheme/racket/geiser/user.rkt
+++ b/scheme/racket/geiser/user.rkt
@@ -15,42 +15,35 @@
(require geiser/enter geiser/eval (for-syntax racket/base))
-(define-syntax (enter! stx)
- (syntax-case stx ()
- [(enter! mod)
- (if (or (not (syntax-e #'mod))
- (module-path? (syntax->datum #'mod)))
- #'(do-enter! 'mod)
- (raise-syntax-error
- #f
- "not a valid module path, and not #f"
- stx
- #'mod))]
- [_ (raise-syntax-error
- #f
- "bad syntax; should be `(enter! <module-path-or-#f>)'"
- stx)]))
-
-(define orig-namespace (current-namespace))
-
-(define (do-enter! mod)
- (if mod
- (begin
- (enter-module mod)
- (let ([ns (module->namespace mod)])
- (current-namespace ns)
- (namespace-require 'geiser/user)))
- (current-namespace orig-namespace)))
-
+(define top-namespace (current-namespace))
+
+(define (enter! mod stx)
+ (cond ((not mod) (current-namespace top-namespace))
+ ((module-path? mod)
+ (enter-module mod)
+ (current-namespace (module->namespace mod)))
+ (else (raise-syntax-error
+ #f
+ "not a valid module path, and not #f"
+ stx
+ mod))))
(define orig-loader (current-load/use-compiled))
+(define orig-reader (current-prompt-read))
+
+(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))
+ (_ form))))
+
(define (init)
(compile-enforce-module-constants #f)
(current-load/use-compiled (module-loader orig-loader))
- (current-prompt-read (compose (make-repl-reader (current-prompt-read))
- current-namespace)))
+ (current-prompt-read
+ (compose (make-repl-reader geiser-read) current-namespace)))
(init)
-
-;;; user.rkt ends here