~ chicken-core (chicken-5) feab48786fcfd9550c2e501aa64c21cdd4d34132
commit feab48786fcfd9550c2e501aa64c21cdd4d34132
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Sat Jul 31 15:41:02 2010 +0200
Commit: felix <felix@call-with-current-continuation.org>
CommitDate: Sat Jul 31 15:41:02 2010 +0200
added ,h and ,ch interpreter commands
diff --git a/csi.scm b/csi.scm
index 6a8d94d2..889915b7 100644
--- a/csi.scm
+++ b/csi.scm
@@ -47,7 +47,7 @@ EOF
parse-option-string chop-separator lookup-script-file
report describe dump hexdump bytevector-data get-config
deldups tty-input?
- history-list history-count history-add history-ref)
+ history-list history-count history-add history-ref history-clear history-show)
(declare
(always-bound
@@ -233,6 +233,21 @@ EOF
(set! history-count (fx+ history-count 1))
x) ) ) )
+(define (history-clear)
+ (vector-fill! history-list (##sys#void)))
+
+(define history-show
+ (let ((newline newline))
+ (lambda ()
+ (do ((i 1 (fx+ i 1)))
+ ((>= i history-count))
+ (printf "#~a: " i)
+ (##sys#with-print-length-limit
+ 80
+ (lambda ()
+ (##sys#print (vector-ref history-list i) #t ##sys#standard-output)))
+ (newline)))))
+
(define (history-ref index)
(let ([i (inexact->exact index)])
(if (and (fx> i 0) (fx<= i history-count))
@@ -335,6 +350,12 @@ EOF
" " (read-line)))))
(if (not (zero? r))
(printf "Editor returned with non-zero exit status ~a" r))))
+ ((ch)
+ (history-clear)
+ (##sys#void))
+ ((h)
+ (history-show)
+ (##sys#void))
((c)
(show-frameinfo selected-frame)
(##sys#void))
@@ -361,6 +382,8 @@ EOF
,l FILENAME ... Load one or more files
,ln FILENAME ... Load one or more files and print result of each top-level expression
,r Show system information
+ ,h Show history of expression results
+ ,ch Clear history of expression results
,e FILENAME Run external editor
,s TEXT ... Execute shell-command
,exn Describe last exception
diff --git a/manual/Using the interpreter b/manual/Using the interpreter
index 1068bb5c..92cf9580 100644
--- a/manual/Using the interpreter
+++ b/manual/Using the interpreter
@@ -141,6 +141,10 @@ The toplevel loop understands a number of special commands:
; ,e FILENAME : Runs an external editor to edit the given {{FILENAME}} (see below for more information).
+; ,h : Shows all previously evaluated expression results.
+
+; ,ch : Clears stored expression results of previously evaluated expressions.
+
; ,exn : Describes the last exception that occurred and adds it to the result history (it can be accessed using the {{#}} notation).
; ,c : Show call-trace items of the most recent error
Trap