summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arith.h2
-rw-r--r--eval.c2
-rw-r--r--eval.h2
-rw-r--r--parser.c13
-rw-r--r--txr.119
5 files changed, 36 insertions, 2 deletions
diff --git a/arith.h b/arith.h
index 177b2417..2ae2bcf2 100644
--- a/arith.h
+++ b/arith.h
@@ -25,7 +25,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-extern val mod_s, bit_s;
+extern val mod_s, bit_s, minus_s;
val make_bignum(void);
val bignum(cnum cn);
val bignum_from_long(long l);
diff --git a/eval.c b/eval.c
index f1e0a53e..6f4cc7c1 100644
--- a/eval.c
+++ b/eval.c
@@ -6014,7 +6014,7 @@ void reg_var(val sym, val val)
mark_special(sym);
}
-static void reg_symacro(val sym, val form)
+void reg_symacro(val sym, val form)
{
loc pcdr = gethash_l(lit("internal initialization"), top_smb, sym, nulloc);
val binding = deref(pcdr);
diff --git a/eval.h b/eval.h
index ad817d99..17e7fb18 100644
--- a/eval.h
+++ b/eval.h
@@ -28,6 +28,7 @@
extern val dwim_s, lambda_s, progn_s, vector_lit_s, vec_list_s, list_s;
extern val hash_lit_s, hash_construct_s, struct_lit_s, qref_s, uref_s;
extern val tree_lit_s, tree_construct_s;
+extern val macro_time_s;
extern val eval_error_s, if_s, call_s, identity_s;
extern val eq_s, eql_s, equal_s, less_s;
extern val car_s, cdr_s;
@@ -66,6 +67,7 @@ val macro_form_p(val form, val menv);
val func_get_name(val fun, val env);
void reg_varl(val sym, val val);
void reg_var(val sym, val val);
+void reg_symacro(val sym, val val);
void reg_fun(val sym, val fun);
void reg_mac(val sym, val fun);
val set_get_symacro(val sym, val form);
diff --git a/parser.c b/parser.c
index 08174154..2c61c742 100644
--- a/parser.c
+++ b/parser.c
@@ -60,6 +60,7 @@
#include "parser.h"
#include "regex.h"
#include "itypes.h"
+#include "arith.h"
#include "buf.h"
#include "vm.h"
#include "txr.h"
@@ -1459,6 +1460,7 @@ val repl(val bindings, val in_stream, val out_stream, val env)
val rw_f = func_f1v(out_stream, repl_warning);
val saved_dyn_env = set_dyn_env(make_env(nil, nil, dyn_env));
val brackets = mkstring(num_fast(repl_level), chr('>'));
+ cnum i;
env_vbind(dyn_env, stderr_s, out_stream);
@@ -1467,6 +1469,17 @@ val repl(val bindings, val in_stream, val out_stream, val env)
reg_varl(car(binding), cdr(binding));
}
+ for (i = 1; i <= 20; i++) {
+ val name = format(nil, lit("*-~d"), num_fast(i), nao);
+ val sym = intern(name, user_package);
+ reg_symacro(sym, list(dwim_s, result_hash_sym,
+ list(macro_time_s,
+ list(mod_s,
+ list(minus_s, var_counter_sym,
+ num_fast(i), nao),
+ num_fast(100), nao), nao), nao));
+ }
+
reg_varl(result_hash_sym, result_hash);
lino_set_completion_cb(ls, provide_completions, 0);
diff --git a/txr.1 b/txr.1
index 3d54cfca..0f3561e8 100644
--- a/txr.1
+++ b/txr.1
@@ -73541,6 +73541,25 @@ Thus, up to the previous hundred results can be referenced:
10
.brev
+.coNP Symbol Macros @, *-1 @, *-2 @, ... @ *-20
+The listener provides small number of symbol macros for referencing the
+results of previous commands in a relative. The macro
+.code *-1
+refers to the value of the immediately previous command. The macro
+.code *-2
+refers to the value of the command before that one and so on.
+
+Note: each of these macros expands to a reference to the
+.code *r
+vector, according to the following pattern:
+
+.mono
+ *-1 --> [*r (mod (- *v 1) 100)]
+ *-2 --> [*r (mod (- *v 2) 100)]
+ ...
+ *-20 --> [*r (mod (- *v 20) 100)]
+.onom
+
.coNP Variable @ *n
.desc
The listener variable