blob: b476de4cd932af3540e8b7b63667796ad53c9a93 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
;;; user.rkt -- global bindings visible to geiser users
;; Copyright (C) 2010 Jose Antonio Ortega Ruiz
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the Modified BSD License. You should
;; have received a copy of the license along with this program. If
;; not, see <http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5>.
;; Start date: Wed Mar 31, 2010 22:24
#lang racket/base
(provide enter!)
(require geiser/enter geiser/eval (for-syntax racket/base))
(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 geiser-read) current-namespace)))
(init)
|