summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parser.c34
-rw-r--r--sysif.c2
-rw-r--r--sysif.h1
-rw-r--r--txr.122
4 files changed, 58 insertions, 1 deletions
diff --git a/parser.c b/parser.c
index 31db6aab..a9a20841 100644
--- a/parser.c
+++ b/parser.c
@@ -369,6 +369,36 @@ val read_eval_stream(val stream, val error_stream, val hash_bang_support)
#if HAVE_TERMIOS
+static void load_rcfile(val name)
+{
+ val resolved_name;
+ val lisp_p = t;
+ val stream = nil;
+ val stat = nil;
+ val catch_syms = cons(error_s, nil);
+
+ uw_catch_begin (catch_syms, sy, va);
+
+ stat = statp(name);
+
+ open_txr_file(name, &lisp_p, &resolved_name, &stream);
+
+ if (stream)
+ read_eval_stream(stream, std_output, nil);
+
+ uw_catch(sy, va)
+ {
+ (void) va;
+ if (stat)
+ format(std_output, lit("** type ~s exception while loading ~s\n"),
+ sy, name, nao);
+ }
+
+ uw_unwind;
+
+ uw_catch_end;
+}
+
static void find_matching_syms(lino_completions_t *cpl,
val package, val prefix,
val line_prefix, char par,
@@ -546,6 +576,7 @@ val repl(val bindings, val in_stream, val out_stream)
val home = getenv_wrap(lit("HOME"));
val histfile = if2(home, format(nil, lit("~a/.txr_history"), home, nao));
char *histfile_u8 = utf8_dup_to(c_str(histfile));
+ val rcfile = if2(home, format(nil, lit("~a/.txr_profile"), home, nao));
val old_sig_handler = set_sig_handler(num(SIGINT), func_n2(repl_intr));
reg_varl(result_hash_sym, result_hash);
@@ -555,6 +586,9 @@ val repl(val bindings, val in_stream, val out_stream)
if (histfile)
lino_hist_load(ls, histfile_u8);
+ if (rcfile)
+ load_rcfile(rcfile);
+
while (!done) {
val prompt = format(nil, lit("~a> "), counter, nao);
val prev_counter = counter;
diff --git a/sysif.c b/sysif.c
index 1d858820..a077ea4c 100644
--- a/sysif.c
+++ b/sysif.c
@@ -643,7 +643,7 @@ static val stat_impl(val obj, int (*statfn)(val, struct stat *),
#endif
}
-static val statp(val path)
+val statp(val path)
{
return stat_impl(path, w_stat, lit("stat"));
}
diff --git a/sysif.h b/sysif.h
index b2b5ce2f..7b7e8d3f 100644
--- a/sysif.h
+++ b/sysif.h
@@ -33,4 +33,5 @@ extern val gid_s, rdev_s, size_s, blksize_s, blocks_s;
extern val atime_s, mtime_s, ctime_s;
val getenv_wrap(val name);
+val statp(val path);
void sysif_init(void);
diff --git a/txr.1 b/txr.1
index 7885ae62..ed4bb90f 100644
--- a/txr.1
+++ b/txr.1
@@ -33655,6 +33655,28 @@ interactive history. Only the
.code :read
command which triggers this parsing mode appears in the history.
+.SS* Interactive Profile File
+
+When the listener starts up, it looks for file called
+.code .txr_profile
+in the user's home directory, as determined by the
+.code HOME
+environment variable. If that variable doesn't exist, no further attempt is
+made to locate this file.
+
+If it exists, the file is expected to be readable and to contain
+\*(TL forms, which are read and evaluated.
+Syntax errors encountered while reading the profile file are displayed
+on standard output, and any exceptions thrown that are derived from
+.code error
+are caught and displayed. The interactive listener starts in spite of these
+situations. Exceptions not derived from error will terminate the process.
+
+The profile file is not read by non-interactive invocations of \*(TX:
+that is, when the
+.code -i
+option isn't present.
+
.SH* DEBUGGER
\*(TX has a simple, crude, built-in debugger. The debugger is invoked by adding
the