summaryrefslogtreecommitdiff
path: root/scheme/plt/geiser/modules.ss
diff options
context:
space:
mode:
Diffstat (limited to 'scheme/plt/geiser/modules.ss')
-rw-r--r--scheme/plt/geiser/modules.ss34
1 files changed, 19 insertions, 15 deletions
diff --git a/scheme/plt/geiser/modules.ss b/scheme/plt/geiser/modules.ss
index 3dea0c3..3d6314d 100644
--- a/scheme/plt/geiser/modules.ss
+++ b/scheme/plt/geiser/modules.ss
@@ -24,30 +24,32 @@
(define (ensure-module-spec spec)
(cond ((symbol? spec) spec)
((not (string? spec)) #f)
- ((not (file-exists? spec)) #f)
- ((absolute-path? spec) `(file ,spec))
- (else spec)))
+ (else `(file ,spec))))
-(define (module-spec->namespace spec)
+(define (module-spec->namespace spec lang)
(let* ((spec (ensure-module-spec spec))
- (contract-handler (lambda (e)
- (load-module spec)
- (enter! #f)
- (module->namespace spec)))
+ (try-lang (lambda (e)
+ (if (symbol? lang)
+ (begin
+ (load-module lang #f (current-namespace))
+ (module->namespace lang))
+ (current-namespace))))
(filesystem-handler (lambda (e)
- (when (symbol? spec)
+ (with-handlers ((exn? try-lang))
(module->namespace `',spec)))))
(if spec
- (with-handlers ((exn:fail:contract? contract-handler)
- (exn:fail:filesystem? filesystem-handler))
+ (with-handlers ((exn:fail:filesystem? filesystem-handler)
+ (exn? try-lang))
(module->namespace spec))
(current-namespace))))
(define nowhere (open-output-nowhere))
-(define (load-module spec . port)
- (parameterize ((current-error-port (if (null? port) nowhere (car port))))
- (eval #`(enter! #,(ensure-module-spec spec)))))
+(define (load-module spec (port #f) (ns #f))
+ (parameterize ((current-error-port (or port nowhere)))
+ (eval #`(enter! #,(ensure-module-spec spec)))
+ (when (namespace? ns)
+ (current-namespace ns))))
(define (namespace->module-path-name ns)
(let ((rmp (variable-reference->resolved-module-path
@@ -67,7 +69,9 @@
(current-library-collection-paths)))
(prefix-len (lambda (p)
(let ((pl (string-length p)))
- (if (= pl (string-prefix-length p path)) pl 0))))
+ (if (= pl (string-prefix-length p path))
+ pl
+ 0))))
(lens (map prefix-len cpaths))
(real-path (substring path (apply max lens))))
(if (absolute-path? real-path)