summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-09-26 20:04:48 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-09-26 20:04:48 -0700
commit35c93525878412abba9acbc46071327c8bfcfc9c (patch)
treea7445b4a0bf67b203d0fbc32d5d55a159b020395 /match.c
parent36f8481e4029ce04776e222653ab3e5aff0c9cd7 (diff)
downloadtxr-35c93525878412abba9acbc46071327c8bfcfc9c.tar.gz
txr-35c93525878412abba9acbc46071327c8bfcfc9c.tar.bz2
txr-35c93525878412abba9acbc46071327c8bfcfc9c.zip
Overhaul of self-load-path mechanism.
The self-load-path symbol macro is as of now deprecated. It simply expands to *load-path*. *load-path* is a new special variable which is dynamically bound to the path of a file being loaded. * eval.c (self_load_path_s): Global variable renamed to load_path_s. (sys_load): Bind *load-path* around processing of loaded file. (me_load): Expand (load x) simply to (sys:load x *load-path*). (set_get_symacro): Function removed. (reg_symacro): New static function. (eval_init): Initialize renamed load_path_s with interned symbol having the name *load-path*. Register the *load-path* special variable. Set up the sel-load-path symbol macro aliasing for *load-path*. * eval.h (self_load_path_s): Declaration renamed. * match.c (v_load): Bind *load-path* around loading or inclusion. * parser.c (load_rcfile): Bind *load-path* around loading of .txr_profile file. * txr.c (txr_main): Bind *load-path* instead of self-load-path symbol macro. * txr.1: Updated documentation for @(load) directive and load macro. Replaced documentation of self-load-path with *load-path*.
Diffstat (limited to 'match.c')
-rw-r--r--match.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/match.c b/match.c
index 8470f29c..75407cd9 100644
--- a/match.c
+++ b/match.c
@@ -3886,13 +3886,14 @@ static val v_load(match_files_ctx *c)
val stream, name;
val txr_lisp_p = nil;
val ret = nil;
- val self_load_path_old = nil;
+ val saved_dyn_env = dyn_env;
open_txr_file(path, &txr_lisp_p, &name, &stream);
uw_simple_catch_begin;
- self_load_path_old = set_get_symacro(self_load_path_s, name);
+ dyn_env = make_env(nil, nil, dyn_env);
+ env_vbind(dyn_env, load_path_s, name);
if (!txr_lisp_p) {
int gc = gc_state(0);
@@ -3942,8 +3943,9 @@ static val v_load(match_files_ctx *c)
ret = (sym == include_s) ? nil : next_spec_k;
}
+ dyn_env = saved_dyn_env;
+
uw_unwind {
- set_get_symacro(self_load_path_s, self_load_path_old);
close_stream(stream, nil);
}