diff options
author | Andy Wingo <wingo@pobox.com> | 2011-06-30 12:56:12 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-06-30 12:56:12 +0200 |
commit | dcada7d8e7f295906983fc762080b5b8de2a209e (patch) | |
tree | 870af243747d6fae754f6b46192bc93c9cf1f8a3 | |
parent | 08969a24079bd73582308dc8e8df0ff7c572f0c6 (diff) | |
download | guile-dcada7d8e7f295906983fc762080b5b8de2a209e.tar.gz |
%load-hook not just for primitive-load
* libguile/load.c (scm_primitive_load_path):
* module/ice-9/boot-9.scm (load-in-vicinity): Call %load-hook as needed.
-rw-r--r-- | libguile/load.c | 9 | ||||
-rw-r--r-- | module/ice-9/boot-9.scm | 5 |
2 files changed, 13 insertions, 1 deletions
diff --git a/libguile/load.c b/libguile/load.c index b06fd7730..3b6ba2b38 100644 --- a/libguile/load.c +++ b/libguile/load.c @@ -806,6 +806,11 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1, SCM filename, exception_on_not_found; SCM full_filename, compiled_filename; int compiled_is_fallback = 0; + SCM hook = *scm_loc_load_hook; + + if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook))) + SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f", + SCM_EOL); if (scm_is_string (args)) { @@ -870,6 +875,10 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1, return SCM_BOOL_F; } + if (!scm_is_false (hook)) + scm_call_1 (hook, (scm_is_true (full_filename) + ? full_filename : compiled_filename)); + if (scm_is_false (full_filename) || (scm_is_true (compiled_filename) && compiled_is_fresh (full_filename, compiled_filename))) diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index a70b9f71e..24f63f592 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -3526,7 +3526,10 @@ module '(ice-9 q) '(make-q q-length))}." (and go-path (fresh-compiled-file-name abs-path go-path))))))) (if cfn - (load-compiled cfn) + (begin + (if %load-hook + (%load-hook abs-path)) + (load-compiled cfn)) (start-stack 'load-stack (primitive-load abs-path))))) |