diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-05-18 20:46:23 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-05-18 20:46:23 -0700 |
commit | 74bc6026ff7e896d157f170a6bf6e590311f06cf (patch) | |
tree | 6cf3e0c8a338be5d222ba48b7ffd4ab6165e2960 /parser.c | |
parent | b4f33cdb14f7d7b820e3b94a6b25b4279753a940 (diff) | |
download | txr-74bc6026ff7e896d157f170a6bf6e590311f06cf.tar.gz txr-74bc6026ff7e896d157f170a6bf6e590311f06cf.tar.bz2 txr-74bc6026ff7e896d157f170a6bf6e590311f06cf.zip |
New feature: self-load-path symbol macro.
* eval.c (self_load_path_s): New symbol variable.
(sys_load): Save, set-up and restore self-load-path
around load.
(set_get_symacro): New function.
(eval_init): Register load function using sys_load_s instead
of redundant intern.
* eval.h (set_get_symacro): Declared.
* match.c (v_load): Save, set-up and restore self-load-path
macro.
* parser.c (load_rcfile): Likewise.
* txr.c (txr_main: Set up self-load-path when opening
file.
* txr.1: Documented self-load-path.
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -404,6 +404,7 @@ static void load_rcfile(val name) val catch_syms = cons(error_s, nil); val path_private_to_me_p = intern(lit("path-private-to-me-p"), user_package); val path_exists_p = intern(lit("path-exists-p"), user_package); + val self_load_path_old = nil; if (!funcall1(path_exists_p, name)) return; @@ -412,6 +413,8 @@ static void load_rcfile(val name) open_txr_file(name, &lisp_p, &resolved_name, &stream); + self_load_path_old = set_get_symacro(self_load_path_s, resolved_name); + if (stream) { if (!funcall1(path_private_to_me_p, statf(stream))) { format(std_output, @@ -431,6 +434,7 @@ static void load_rcfile(val name) } uw_unwind { + set_get_symacro(self_load_path_s, self_load_path_old); if (stream) close_stream(stream, nil); } |