emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/geiser-racket 65447c4 138/191: racket: handling correctly


From: Philip Kaludercic
Subject: [nongnu] elpa/geiser-racket 65447c4 138/191: racket: handling correctly submodules in load handler during , enter
Date: Sun, 1 Aug 2021 18:32:16 -0400 (EDT)

branch: elpa/geiser-racket
commit 65447c49d68b887d937e2d26ed84b29ecc163410
Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
Commit: Jose Antonio Ortega Ruiz <jao@gnu.org>

    racket: handling correctly submodules in load handler during ,enter
    
    That is, complying to the submodule loading protocol (cf. racket's own
    enter!).
---
 geiser/enter.rkt | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/geiser/enter.rkt b/geiser/enter.rkt
index 6da8c7a..aadf5af 100644
--- a/geiser/enter.rkt
+++ b/geiser/enter.rkt
@@ -84,25 +84,34 @@
 (define (notify re? path)
   (when re? (fprintf (current-error-port) " [re-loading ~a]\n" path)))
 
+(define (module-name? name)
+  (and name (not (and (pair? name) (not (car name))))))
+
 (define ((enter-load/use-compiled orig re?) path name)
   (when (inhibit-eval)
     (raise (make-exn:fail "namespace not found" (current-continuation-marks))))
-  ;; (printf "Loading ~s: ~s~%" name path)
-  (if (and name (not (list? name)))
+  (printf "Loading ~s: ~s~%" name path)
+  (if (module-name? 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)))]
-             [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 real-path]) (eval code)))
+      (with-handlers ([(lambda (exn)
+                         (and (pair? name) (exn:get-module-code? exn)))
+                       ;; Load-handler protocol: quiet failure when a
+                       ;; submodule is not found
+                       (lambda (exn) (void))])
+        (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 real-path])
+            (eval code))))
       ;; Not a module:
       (begin (notify re? path) (orig path name))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]