[plt-scheme] Re: Best place to install custom current-module-name-resolver?
On Thu, 2008-04-10 at 08:35 -0700, Derick Eddington wrote:
> Hi, I've made a hacked current-module-name-resolver so it can find
> module/library files with more file type extensions than only .ss
Might as well post it:
(let ([cmnr (current-module-name-resolver)])
(current-module-name-resolver
(case-lambda
[(a) (cmnr a)]
[(mod-path src-mod . args)
#;(printf "*** My current-module-name-resolver got: ~s\n"
(cons mod-path (cons src-mod args)))
(if (list? mod-path)
(apply cmnr mod-path src-mod args)
(let ([mp (if (symbol? mod-path)
(resolved-module-path-name (cmnr mod-path src-mod #f #f))
mod-path)])
(let loop ([exts '(".ss" ".sls" ".scm" ".sch" ".mzscheme.ss"
".mzscheme.sls" ".mzscheme.scm"
".mzscheme.sch")]
[last-ex #f])
(if (null? exts)
(raise last-ex)
(let ([r (with-handlers ([exn:fail? values])
#;(printf "*** Trying ~a\n" (car exts))
(apply cmnr
((if (string? mp) path->string values)
(path-replace-suffix mp (car exts)))
src-mod args))])
(if (exn:fail? r)
(loop (cdr exts) r)
r))))))])))
--
: Derick
----------------------------------------------------------------