summaryrefslogtreecommitdiff
path: root/module/system/repl/command.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-03-04 11:16:15 +0100
committerAndy Wingo <wingo@pobox.com>2011-03-04 11:16:15 +0100
commit090f14b890ec31844bca6b93256a39d3bd80aba3 (patch)
tree9daa890782ccab2bc4a4cf5e938e86bf2bdfba56 /module/system/repl/command.scm
parent47b86dbf4dc3da2f4d6d41a018cd221fbf0823ee (diff)
downloadguile-090f14b890ec31844bca6b93256a39d3bd80aba3.tar.gz
repl: terminal-width by default
* module/system/repl/command.scm (terminal-width): New parameter that will use the true terminal width if unset. (backtrace, locals): Default to (terminal-width). (width): Simplify.
Diffstat (limited to 'module/system/repl/command.scm')
-rw-r--r--module/system/repl/command.scm28
1 files changed, 18 insertions, 10 deletions
diff --git a/module/system/repl/command.scm b/module/system/repl/command.scm
index 2ae266f7b..685eebb0b 100644
--- a/module/system/repl/command.scm
+++ b/module/system/repl/command.scm
@@ -71,7 +71,19 @@
(define *show-table*
'((show (warranty w) (copying c) (version v))))
-(define *width* 72)
+(define terminal-width
+ (let ((set-width #f))
+ (case-lambda
+ (()
+ (or set-width
+ (let ((w (false-if-exception (string->number (getenv "COLUMNS")))))
+ (and (integer? w) (exact? w) (> w 0) w))
+ 72))
+ ((w)
+ (if (or (not w) (and (integer? w) (exact? w) (> w 0)))
+ (set! set-width w)
+ (error "Expected a column number (a positive integer)" w))))))
+
(define (group-name g) (car g))
(define (group-commands g) (cdr g))
@@ -548,7 +560,7 @@ Trace execution."
(format #t "Nothing to debug.~%"))))))))
(define-stack-command (backtrace repl #:optional count
- #:key (width *width*) full?)
+ #:key (width (terminal-width)) full?)
"backtrace [COUNT] [#:width W] [#:full? F]
Print a backtrace.
@@ -628,7 +640,7 @@ With an argument, select a frame by index, then show it."
Print the procedure for the selected frame."
(repl-print repl (frame-procedure cur)))
-(define-stack-command (locals repl #:key (width *width*))
+(define-stack-command (locals repl #:key (width (terminal-width)))
"locals
Show local variables.
@@ -819,13 +831,9 @@ Set debug output width.
Set the number of screen columns in the output from `backtrace' and
`locals'."
- (if (and x (not (integer? x)))
- (error "expected a column number (a non-negative integer)" x)
- (let ((w (or x
- (false-if-exception (string->number (getenv "COLUMNS")))
- 72)))
- (format #t "Setting screen width to ~a columns~%" w)
- (set! *width* w))))
+ (terminal-width x)
+ (format #t "Set screen width to ~a columns.~%" (terminal-width)))
+
;;;