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 | a2d98ba063616fc56c6888641c77b55b562fc9ab (patch) | |
tree | 6cf3e0c8a338be5d222ba48b7ffd4ab6165e2960 /parser.c | |
parent | dc791857cfd41fec131d2645409bf6451eb4635b (diff) | |
download | txr-a2d98ba063616fc56c6888641c77b55b562fc9ab.tar.gz txr-a2d98ba063616fc56c6888641c77b55b562fc9ab.tar.bz2 txr-a2d98ba063616fc56c6888641c77b55b562fc9ab.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); } |