#| -*-Scheme-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/debug.scm,v 14.25 1991/05/15 18:13:49 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/debug.scm,v 14.26 1991/05/15 21:18:07 cph Exp $
Copyright (c) 1988-91 Massachusetts Institute of Technology
(length subproblems)
" inclusive).")
(top-level-loop))))))))))
-
+\f
(define (prompt-for-nonnegative-integer prompt limit)
+ (prompt-for-integer prompt 0 limit))
+
+(define (prompt-for-integer prompt lower upper)
(let loop ()
(let ((expression
(prompt-for-expression
- (string-append prompt
- (if limit
- (string-append " (0 through "
- (number->string (-1+ limit))
- " inclusive)")
- "")))))
- (cond ((not (exact-nonnegative-integer? expression))
- (debugger-failure prompt " must be nonnegative integer.")
+ (string-append
+ prompt
+ (if lower
+ (if upper
+ (string-append " (" (number->string lower)
+ " through "
+ (number->string (- upper 1))
+ " inclusive)")
+ (string-append " (minimum " (number->string lower) ")"))
+ (if upper
+ (string-append " (maximum "
+ (number->string (- upper 1))
+ ")")
+ ""))))))
+ (cond ((not (exact-integer? expression))
+ (debugger-failure prompt " must be exact integer.")
(loop))
- ((and limit (>= expression limit))
+ ((and lower (< expression lower))
+ (debugger-failure prompt " too small.")
+ (loop))
+ ((and upper (>= expression upper))
(debugger-failure prompt " too large.")
(loop))
(else
(if (null? restarts)
(debugger-failure "No options to choose from.")
(let ((n-restarts (length restarts))
- (invoke-option
- (lambda (n)
- (invoke-restart-interactively (list-ref restarts n)))))
- (presentation
- (lambda ()
- (let ((port (current-output-port)))
- (if (= n-restarts 1)
- (begin
- (write-string "There is only one option:" port)
- (newline port)
- (write-restarts restarts port)
- (if (prompt-for-confirmation "Use this option")
- (invoke-option 0)))
- (begin
- (write-string "Choose an option by number:" port)
- (newline port)
- (write-restarts restarts port)
- (invoke-option
- (prompt-for-nonnegative-integer "Option number"
- n-restarts)))))))))))
-
-(define (write-restarts restarts port)
- (do ((restarts restarts (cdr restarts))
- (index 0 (1+ index)))
- ((null? restarts))
- (write-string (string-pad-left (number->string index) 3) port)
- (write-string ": " port)
- (write-restart-report (car restarts) port)
- (newline port)))
+ (write-index
+ (lambda (index port)
+ (write-string (string-pad-left (number->string index) 3) port)
+ (write-string ":" port))))
+ (let ((invoke-option
+ (lambda (n)
+ (invoke-restart-interactively
+ (list-ref restarts (- n-restarts n))))))
+ (presentation
+ (lambda ()
+ (let ((port (current-output-port)))
+ (if (= n-restarts 1)
+ (begin
+ (write-string "There is only one option:" port)
+ (write-restarts restarts port write-index)
+ (if (prompt-for-confirmation "Use this option")
+ (invoke-option 1)))
+ (begin
+ (write-string "Choose an option by number:" port)
+ (write-restarts restarts port write-index)
+ (invoke-option
+ (prompt-for-integer "Option number"
+ 1
+ (+ n-restarts 1)))))))))))))
\f
;;;; Advanced hacking commands
#| -*-Scheme-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/rep.scm,v 14.19 1991/03/14 04:27:13 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/rep.scm,v 14.20 1991/05/15 21:17:51 cph Exp $
Copyright (c) 1988-91 Massachusetts Institute of Technology
(declare (usual-integrations))
\f
+(define repl:allow-restart-notifications?
+ true)
+
(define (initialize-package!)
(set! *nearest-cmdl* false)
(set! with-cmdl/input-port
message))
(if condition
(cmdl-message/append
- (if hook/error-decision
+ (if (and hook/error-decision (condition/error? condition))
(cmdl-message/active
(lambda (cmdl)
cmdl
(hook/error-decision)))
(cmdl-message/null))
- (condition-restarts-message condition))
+ (if repl:allow-restart-notifications?
+ (condition-restarts-message condition)
+ (cmdl-message/null)))
(cmdl-message/null))
(if (eq? 'INHERIT environment)
(cmdl-message/null)
;To continue, call RESTART with an option number:" port)
(write-restarts (filter-restarts (condition/restarts condition)) port
(lambda (index port)
- (write-string " (RESTART " port)
+ (write-string "; (RESTART " port)
(write index port)
(write-string ") =>" port)))))))
(write-string ";Choose an option by number:" port)
(write-restarts restarts port
(lambda (index port)
+ (write-string ";" port)
(write-string (string-pad-left (number->string index) 3)
port)
(write-string ":" port)))
(do ((restarts restarts (cdr restarts))
(index (length restarts) (- index 1)))
((null? restarts))
- (write-string ";" port)
(write-index index port)
(write-string " " port)
(write-restart-report (car restarts) port)