[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/geiser-racket 739aaec 010/191: Racket: improvements in non
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/geiser-racket 739aaec 010/191: Racket: improvements in non-loaded module location. |
Date: |
Sun, 1 Aug 2021 18:31:50 -0400 (EDT) |
branch: elpa/geiser-racket
commit 739aaec95d4a1d638cbcef54af5a69080b4a88ed
Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
Commit: Jose Antonio Ortega Ruiz <jao@gnu.org>
Racket: improvements in non-loaded module location.
---
geiser/modules.rkt | 42 +++++++++++++++++++++++++++++-------------
1 file changed, 29 insertions(+), 13 deletions(-)
diff --git a/geiser/modules.rkt b/geiser/modules.rkt
index 299baee..5022891 100644
--- a/geiser/modules.rkt
+++ b/geiser/modules.rkt
@@ -27,7 +27,7 @@
[(not (string? spec)) #f]
[else `(file ,spec)]))
-(define (module-spec->namespace spec (lang #f))
+(define (module-spec->namespace spec (lang #f) (no-current #f))
(let ([spec (ensure-module-spec spec)]
[try-lang (lambda (_)
(with-handlers ([exn? (const (current-namespace))])
@@ -37,7 +37,7 @@
(module->namespace lang)))))])
(or (and spec
(with-handlers ([exn? try-lang]) (get-namespace spec)))
- (current-namespace))))
+ (if no-current #f (current-namespace)))))
(define nowhere (open-output-nowhere))
@@ -54,22 +54,24 @@
(resolved-module-path-name rmp))))
(define (module-spec->path-name spec)
- (with-handlers ([exn? (lambda (_) #f)])
- (let ([ns (module-spec->namespace (ensure-module-spec spec))])
- (namespace->module-path-name ns))))
+ (and (symbol? spec)
+ (or (get-path spec)
+ (register-path spec
+ (namespace->module-path-name
+ (module-spec->namespace spec) #f #t)))))
(define (module-path-name->name path)
(cond [(path? path)
- (let* ((path (path->string path))
- (cpaths (map (compose path->string path->directory-path)
- (current-library-collection-paths)))
- (prefix-len (lambda (p)
+ (let* ([path (path->string path)]
+ [cpaths (map (compose path->string path->directory-path)
+ (current-library-collection-paths))]
+ [prefix-len (lambda (p)
(let ((pl (string-length p)))
(if (= pl (string-prefix-length p path))
pl
- 0))))
- (lens (map prefix-len cpaths))
- (real-path (substring path (apply max lens))))
+ 0)))]
+ [lens (map prefix-len cpaths)]
+ [real-path (substring path (apply max lens))])
(if (absolute-path? real-path)
(call-with-values (lambda () (split-path path))
(lambda (_ basename __) (path->string basename)))
@@ -97,7 +99,12 @@
(define (visit-module-path path kind acc)
(case kind
[(file) (let ((entry (path->entry path)))
- (if entry (cons entry acc) acc))]
+ (if (not entry)
+ acc
+ (begin
+ (register-path (string->symbol entry)
+ (build-path (current-directory) path))
+ (cons entry acc))))]
[(dir) (cond ((skippable-dir? path) (values acc #f))
((or (file-exists? (build-path path "main.rkt"))
(file-exists? (build-path path "main.ss")))
@@ -114,7 +121,16 @@
(define (known-modules)
(sort (foldl find-modules '() (current-library-collection-paths)) string<?))
+(define registered (make-hash))
+
+(define (get-path mod) (hash-ref registered mod #f))
+
+(define (register-path mod path)
+ (hash-set! registered mod path)
+ path)
+
(define module-cache #f)
+
(define (update-module-cache)
(when (not module-cache) (set! module-cache (known-modules))))
- [nongnu] elpa/geiser-racket 7a16f5a 012/191: Racket: using `_' for naming unknown args in autodoc., (continued)
- [nongnu] elpa/geiser-racket 7a16f5a 012/191: Racket: using `_' for naming unknown args in autodoc., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 130c38e 028/191: Racket: support for gracket-text, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket cd122ff 021/191: Tweaks to scheme implementation selection, and docs for it., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 26ba1f2 011/191: Racket: improvements in module lookups., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket c03596d 013/191: Wee refactoring., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket c6c6bba 026/191: Support for evaluation warnings, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket c07a42d 034/191: Racket: using meta-commands instead of dynamic-require (#30347), Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket d8076a5 029/191: Couple nits, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket de36aed 027/191: Better REPL exit command, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 15cb8fb 006/191: Racket: providing error contexts, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 739aaec 010/191: Racket: improvements in non-loaded module location.,
Philip Kaludercic <=
- [nongnu] elpa/geiser-racket 912e318 020/191: Racket: catching errors during contract retrieval., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket b53aba6 036/191: Racket: , eval -> , geiser-eval, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 2ef38a5 037/191: Racket: , eval -> , geiser-eval, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 9790b39 039/191: Racket: little evaluation nits, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 2b2b13f 043/191: Nit, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket d789d5f 046/191: Racket: fix for prompt display on , enter, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 1c3ae9f 018/191: Racket: showing contracts in module documentation., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket e1b6db4 033/191: Racket: new meta-commands: , eval , apply , no-values, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 47afcd9 030/191: Racket nit: racket/base instead of scheme/base, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket a8e6427 032/191: Racket: , enter meta-command instead of namespace clobbering, Philip Kaludercic, 2021/08/01