From f711590ceae82493b8a87eba0bfaaed30af06c34 Mon Sep 17 00:00:00 2001
From: Kaz Kylheku <kaz@kylheku.com>
Date: Wed, 13 Jan 2016 20:37:46 -0800
Subject: Pastes produced using :read are now numbered.

* parser.c (read_eval_read_last): New argument: counter.
Incorporate counter into name of stream.
(repl): Pass prev_counter into read_eval_read_last
so the paste inherits the line number of the :read
command.
---
 parser.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/parser.c b/parser.c
index fe5527b2..040dd54b 100644
--- a/parser.c
+++ b/parser.c
@@ -615,13 +615,14 @@ static val repl_intr(val signo, val async_p)
   uw_throw(intr_s, lit("intr"));
 }
 
-static val read_eval_ret_last(val env, val in_stream, val out_stream)
+static val read_eval_ret_last(val env, val counter,
+                              val in_stream, val out_stream)
 {
   val lineno = one;
+  val name = format(nil, lit("paste-~a"), counter, nao);
 
   for (;; lineno = succ(lineno)) {
-    val form = lisp_parse(in_stream, out_stream, colon_k,
-                          lit("paste"), lineno);
+    val form = lisp_parse(in_stream, out_stream, colon_k, name, lineno);
     val parser = get_parser(in_stream);
     val value = eval_intrinsic(form, nil);
 
@@ -735,7 +736,8 @@ val repl(val bindings, val in_stream, val out_stream)
       } else {
         val value = if3(form != read_k,
                         eval_intrinsic(form, repl_env),
-                        read_eval_ret_last(repl_env, in_stream, out_stream));
+                        read_eval_ret_last(repl_env, prev_counter,
+                                           in_stream, out_stream));
         reg_varl(var_sym, value);
         sethash(result_hash, var_counter, value);
         prinl(value, out_stream);
-- 
cgit v1.2.3