diff options
Diffstat (limited to 'libslang/slsh/lib/slsh.rc')
-rw-r--r-- | libslang/slsh/lib/slsh.rc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/libslang/slsh/lib/slsh.rc b/libslang/slsh/lib/slsh.rc new file mode 100644 index 0000000..10ce328 --- /dev/null +++ b/libslang/slsh/lib/slsh.rc @@ -0,0 +1,46 @@ +% -*- slang -*- + +% This file gets loaded whenever slsh runs. Its primary purpose is to define +% some functions that are useful in scripts, and to set up some local paths + +static define dir_exists (dir) +{ + variable s = stat_file (dir); + if (s == NULL) return 0; + return stat_is ("dir", s.st_mode); +} + +%!%+ +%\function{prepend_to_slang_load_path} +%\synopsis{Prepend a directory to the load-path} +%\usage{prepend_to_slang_load_path (String_Type dir)} +%\description +% This function adds a directory to the beginning of the interpreter's +% load-path. +%\seealso{append_to_slang_load_path, set_slang_load_path} +%!%- +public define prepend_to_slang_load_path (p) +{ + if (dir_exists (p)) + set_slang_load_path (strcat (p, ":", get_slang_load_path ())); +} + +%!%+ +%\function{append_to_slang_load_path} +%\synopsis{Append a directory to the load-path} +%\usage{append_to_slang_load_path (String_Type dir)} +%\description +% This function adds a directory to the end of the interpreter's +% load-path. +%\seealso{prepend_to_slang_load_path, set_slang_load_path} +%!%- +public define append_to_slang_load_path (p) +{ + if (dir_exists (p)) + set_slang_load_path (get_slang_load_path (), ":", p); +} + +() = evalfile ("autoload.sl"); + +% Add local additions here + |