From 5dddc9d9c2f39547c95542b458575f38d6aca539 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 12 Feb 2018 08:35:34 -0800 Subject: New listener variable: *listener-pprint-s*. * parser.c (listener_pprint_s): New symbol variable. (repl): Check new variable after each evaluation and print accordingly. (parse_init): Initialize listener_print_s with interned symbol and register the variable. * txr.1: Document *listener-pprint-s*. --- parser.c | 7 ++++++- txr.1 | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/parser.c b/parser.c index 4f4bcdae..b47e642f 100644 --- a/parser.c +++ b/parser.c @@ -62,6 +62,7 @@ val parser_s, unique_s, circref_s; val listener_hist_len_s, listener_multi_line_p_s, listener_sel_inclusive_p_s; +val listener_pprint_s; val rec_source_loc_s; val intr_s; @@ -1140,6 +1141,7 @@ val repl(val bindings, val in_stream, val out_stream) val hist_len_var = lookup_global_var(listener_hist_len_s); val multi_line_var = lookup_global_var(listener_multi_line_p_s); val sel_inclusive_var = lookup_global_var(listener_sel_inclusive_p_s); + val pprint_var = lookup_global_var(listener_pprint_s); val rw_f = func_f1v(out_stream, repl_warning); val saved_dyn_env = set_dyn_env(make_env(nil, nil, dyn_env)); @@ -1240,9 +1242,10 @@ val repl(val bindings, val in_stream, val out_stream) eval_intrinsic(form, nil), read_eval_ret_last(nil, prev_counter, in_stream, out_stream)); + val pprin = cdr(pprint_var); reg_varl(var_sym, value); sethash(result_hash, var_counter, value); - prinl(value, out_stream); + if3(pprin, pprinl, prinl)(value, out_stream); lino_set_result(ls, utf8_dup_to(c_str(tostring(value)))); lino_hist_add(ls, line_u8); } @@ -1324,6 +1327,7 @@ void parse_init(void) listener_hist_len_s = intern(lit("*listener-hist-len*"), user_package); listener_multi_line_p_s = intern(lit("*listener-multi-line-p*"), user_package); listener_sel_inclusive_p_s = intern(lit("*listener-sel-inclusive-p*"), user_package); + listener_pprint_s = intern(lit("*listener-pprint-p*"), user_package); rec_source_loc_s = intern(lit("*rec-source-loc*"), user_package); unique_s = gensym(nil); prot1(&stream_parser_hash); @@ -1333,6 +1337,7 @@ void parse_init(void) reg_var(listener_hist_len_s, num_fast(500)); reg_var(listener_multi_line_p_s, t); reg_var(listener_sel_inclusive_p_s, nil); + reg_var(listener_pprint_s, nil); reg_var(rec_source_loc_s, nil); reg_fun(circref_s, func_n1(circref)); } diff --git a/txr.1 b/txr.1 index ef9dab94..dbde5745 100644 --- a/txr.1 +++ b/txr.1 @@ -62500,6 +62500,27 @@ that the selection is determined by the starting and ending character, and includes them. This type of selection pairs well with a block-shaped cursor. +.coNP Special variable @ *listener-pprint-p* +.desc +This Boolean variable controls how the listener prints the results +of evaluations. +It is +.code nil +by default. + +When the variable is +.codn nil , +the evaluation result of each line entered into the listener is printed +using the +.code prinl +function. Thus values are rendered in a machine-readable syntax, ensuing +read/print consistency. + +If the variable is set true, the evaluation result of each line is printed +using the +.code pprinl +function. + .SH* SETUID/SETGID OPERATION On platforms with the Unix filesystem and process security model, \*(TX has -- cgit v1.2.3