pull/218/head
Matthew Butterick 4 years ago
parent 4f4dc34850
commit bba9cff6c9

@ -1 +1 @@
1578696364 1578793791

@ -16,10 +16,11 @@
(let-values ([(dir name dir?) (split-path path)]) (let-values ([(dir name dir?) (split-path path)])
dir)) dir))
(define (get-path-to-override [file-or-dir (current-directory)]) (define (get-path-to-override maybe-dir)
(define starting-dir (if (directory-exists? file-or-dir) (define starting-dir (cond
file-or-dir [(not maybe-dir) (current-directory)]
(dirname file-or-dir))) [(directory-exists? maybe-dir) maybe-dir]
[else (dirname maybe-dir)]))
(let loop ([dir starting-dir][path default-directory-require]) (let loop ([dir starting-dir][path default-directory-require])
(and dir ; dir is #f when it hits the top of the filesystem (and dir ; dir is #f when it hits the top of the filesystem
(let ([simplified-path (simplify-path (path->complete-path path starting-dir))]) (let ([simplified-path (simplify-path (path->complete-path path starting-dir))])
@ -40,11 +41,12 @@
#'(begin #'(begin
(provide (prefix-out setup: NAME-THUNKED) DEFAULT-NAME) (provide (prefix-out setup: NAME-THUNKED) DEFAULT-NAME)
(define DEFAULT-NAME DEFAULT-VALUE) (define DEFAULT-NAME DEFAULT-VALUE)
(define NAME-FAIL-THUNKED (λ _ DEFAULT-NAME))
;; can take a dir argument that sets start point for (get-path-to-override) search. ;; can take a dir argument that sets start point for (get-path-to-override) search.
(define NAME-THUNKED (λ get-path-args (define (NAME-THUNKED [dir #false])
(with-handlers ([exn:fail? NAME-FAIL-THUNKED]) (with-handlers ([exn:fail? (λ (exn) DEFAULT-NAME)])
(dynamic-require `(submod ,(apply get-path-to-override get-path-args) WORLD-SUBMOD) 'NAME NAME-FAIL-THUNKED))))))])) (dynamic-require `(submod ,(get-path-to-override dir) WORLD-SUBMOD)
'NAME
(λ () DEFAULT-NAME))))))]))
(define-settable cache-watchlist null) (define-settable cache-watchlist null)
(define-settable envvar-watchlist null) (define-settable envvar-watchlist null)

Loading…
Cancel
Save