[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/geiser-racket c5e7ea8 100/191: Little cleanups
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/geiser-racket c5e7ea8 100/191: Little cleanups |
Date: |
Sun, 1 Aug 2021 18:32:08 -0400 (EDT) |
branch: elpa/geiser-racket
commit c5e7ea835b7664903b771ca124e2704d9054610b
Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
Commit: Jose Antonio Ortega Ruiz <jao@gnu.org>
Little cleanups
---
geiser/enter.rkt | 112 ++++++++++++++++++++++++++++---------------------------
1 file changed, 58 insertions(+), 54 deletions(-)
diff --git a/geiser/enter.rkt b/geiser/enter.rkt
index e996527..d7802f5 100644
--- a/geiser/enter.rkt
+++ b/geiser/enter.rkt
@@ -19,6 +19,12 @@
(struct mod (name load-path timestamp depends))
+(define (make-mod name path ts code)
+ (let ([deps (if code
+ (apply append (map cdr (module-compiled-imports code)))
+ null)])
+ (mod name (path->string path) ts deps)))
+
(define loaded (make-hash))
(define (module-loaded? path)
@@ -81,62 +87,60 @@
(define ((enter-load/use-compiled orig re?) path name)
(when (inhibit-eval)
- (raise (make-exn:fail "namespace not found"
- (current-continuation-marks))))
+ (raise (make-exn:fail "namespace not found" (current-continuation-marks))))
(if name
;; Module load:
- (let ([code (get-module-code
- path "compiled"
- (lambda (e)
- (parameterize ([compile-enforce-module-constants #f])
- (compile e)))
- (lambda (ext loader?) (load-extension ext) #f)
- #:notify (lambda (chosen) (notify re? chosen)))]
- [path (normal-case-path
- (simplify-path
- (path->complete-path path
- (or (current-load-relative-directory)
- (current-directory)))))])
- ;; Record module timestamp and dependencies:
- (let ([m (mod name
- (path->string path)
- (get-timestamp path)
- (if code
- (apply append
- (map cdr
- (module-compiled-imports code)))
- null))])
- (add-paths! m (resolve-paths path)))
- ;; Evaluate the module:
- (parameterize ([current-module-declare-source path])
- (eval code)))
+ (let* ([code (get-module-code
+ path "compiled"
+ (lambda (e)
+ (parameterize ([compile-enforce-module-constants #f])
+ (compile e)))
+ (lambda (ext loader?) (load-extension ext) #f)
+ #:notify (lambda (chosen) (notify re? chosen)))]
+ [dir (or (current-load-relative-directory) (current-directory))]
+ [path (path->complete-path path dir)]
+ [path (normal-case-path (simplify-path path))])
+ (define-values (ts real-path) (get-timestamp path))
+ (add-paths! (make-mod name path ts code) (resolve-paths path))
+ (parameterize ([current-module-declare-source path]) (eval code)))
;; Not a module:
- (begin
- (notify re? path)
- (orig path name))))
+ (begin (notify re? path) (orig path name))))
+
(define (get-timestamp path)
- (file-or-directory-modify-seconds path #f (lambda () -inf.0)))
-
-(define (check-latest mod)
- (let ([mpi (module-path-index-join mod #f)]
- [done (make-hash)])
- (let loop ([mpi mpi])
- (let* ([rpath (module-path-index-resolve mpi)]
- [path (resolved-module-path-name rpath)])
- (when (path? path)
- (let ([path (normal-case-path path)])
- (unless (hash-ref done path #f)
- (hash-set! done path #t)
- (let ([mod (hash-ref loaded path #f)])
- (when mod
- (for-each loop (mod-depends mod))
- (let ([ts (get-timestamp path)])
- (when (ts . > . (mod-timestamp mod))
- (let ([orig (current-load/use-compiled)])
- (parameterize ([current-load/use-compiled
- (enter-load/use-compiled orig #f)]
- [current-module-declare-name rpath])
- ((enter-load/use-compiled orig #t)
- path
- (mod-name mod)))))))))))))))
+ (let ([ts (file-or-directory-modify-seconds path #f (lambda () #f))])
+ (if ts
+ (values ts path)
+ (if (regexp-match? #rx#"[.]rkt$" (path->bytes path))
+ (let* ([alt-path (path-replace-suffix path #".ss")]
+ [ts (file-or-directory-modify-seconds alt-path
+ #f
+ (lambda () #f))])
+ (if ts
+ (values ts alt-path)
+ (values -inf.0 path)))
+ (values -inf.0 path)))))
+
+(define (check-latest mod flags)
+ (define mpi (module-path-index-join mod #f))
+ (define done (make-hash))
+ (let loop ([mpi mpi])
+ (define rpath (module-path-index-resolve mpi))
+ (define path (let ([p (resolved-module-path-name rpath)])
+ (if (pair? p) (car p) p)))
+ (when (path? path)
+ (define npath (normal-case-path path))
+ (unless (hash-ref done npath #f)
+ (hash-set! done npath #t)
+ (define mod (hash-ref loaded npath #f))
+ (when mod
+ (for-each loop (mod-depends mod))
+ (define-values (ts actual-path) (get-timestamp npath))
+ (when (ts . > . (mod-timestamp mod))
+ (define orig (current-load/use-compiled))
+ (parameterize ([current-load/use-compiled
+ (enter-load/use-compiled orig #f flags)]
+ [current-module-declare-name rpath]
+ [current-module-declare-source actual-path])
+ ((enter-load/use-compiled orig #t flags)
+ npath (mod-name mod)))))))))
- [nongnu] elpa/geiser-racket 74a223e 008/191: Racket: autodoc for struct constructors, (continued)
- [nongnu] elpa/geiser-racket 74a223e 008/191: Racket: autodoc for struct constructors, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 4c3903a 063/191: Better module help, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 1f64738 066/191: Racket: showing submodules in module help, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 1f2bc48 070/191: Racket: more information in symbol documentation, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket cd7378b 089/191: Racket: indentation for all 'for' forms, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 41f65a1 076/191: Fixes for locals scanning, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket d0d80d8 079/191: Racket: no errors , entering an R5RS module, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket dc63508 081/191: Racket: use the proper interaction port for input (#32844), Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 12dc25e 077/191: Racket: ', enter "foo"' as a synonym of ', enter (file "foo")', Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 13dfcf3 075/191: Racket: #lang, require and provide as keywords, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket c5e7ea8 100/191: Little cleanups,
Philip Kaludercic <=
- [nongnu] elpa/geiser-racket 7cefe7f 074/191: No more interning in the scheme reader, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket f9fc642 102/191: Racket: fix for enter!, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 5e2184b 103/191: racket: displaying images also during evaluations, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 81ecf42 118/191: More Racket for/* forms indentation from Diogo, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket b924983 108/191: Autoload cookies in geiser.el, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket a22f8e2 117/191: Indentation rule for match/values (Diogo F.S. Ramos), Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 3e306cf 112/191: Racket: indentation for `local'., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket b86cf1f 116/191: Configurable keyword case sensitivity, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket e4707d2 105/191: racket: autodoc for PLAI's define-type, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 90c38d6 121/191: A better solution to the funky filename problem, Philip Kaludercic, 2021/08/01