diff options
author | Michael Gran <spk121@yahoo.com> | 2011-02-20 21:53:46 -0800 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-03-04 11:01:48 +0100 |
commit | 47b86dbf4dc3da2f4d6d41a018cd221fbf0823ee (patch) | |
tree | 166b7c9522f562f168124a8c22f5131ef5d556d0 | |
parent | c7d6f8b27949e12b6e358e4c9580affddb339af6 (diff) | |
download | guile-47b86dbf4dc3da2f4d6d41a018cd221fbf0823ee.tar.gz |
Add ,width meta-command to set screen width in debug output
This meta-command allows one to set the default number of columns
that output from ,backtrace and ,locals shall occupy.
* doc/ref/scheme-using.texi (Debug Commands): document ,width
* module/system/repl/command.scm (*width*): new var
(backtrace, locals): use *width* in optarg
(width): new meta-command
-rw-r--r-- | doc/ref/scheme-using.texi | 6 | ||||
-rw-r--r-- | module/system/repl/command.scm | 21 |
2 files changed, 24 insertions, 3 deletions
diff --git a/doc/ref/scheme-using.texi b/doc/ref/scheme-using.texi index 126b84590..a119d4218 100644 --- a/doc/ref/scheme-using.texi +++ b/doc/ref/scheme-using.texi @@ -337,6 +337,12 @@ Show the VM registers associated with the current frame. @xref{Stack Layout}, for more information on VM stack frames. @end deffn +@deffn {REPL Command} width [cols] +Sets the number of display columns in the output of @code{,backtrace} +and @code{,locals} to @var{cols}. If @var{cols} is not given, the width +of the terminal is used. +@end deffn + The next 3 commands work at any REPL. @deffn {REPL Command} break proc diff --git a/module/system/repl/command.scm b/module/system/repl/command.scm index 58ce12e62..2ae266f7b 100644 --- a/module/system/repl/command.scm +++ b/module/system/repl/command.scm @@ -71,6 +71,8 @@ (define *show-table* '((show (warranty w) (copying c) (version v)))) +(define *width* 72) + (define (group-name g) (car g)) (define (group-commands g) (cdr g)) @@ -546,7 +548,7 @@ Trace execution." (format #t "Nothing to debug.~%")))))))) (define-stack-command (backtrace repl #:optional count - #:key (width 72) full?) + #:key (width *width*) full?) "backtrace [COUNT] [#:width W] [#:full? F] Print a backtrace. @@ -626,12 +628,12 @@ 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) +(define-stack-command (locals repl #:key (width *width*)) "locals Show local variables. Show locally-bound variables in the selected frame." - (print-locals cur)) + (print-locals cur #:width width)) (define-stack-command (error-message repl) "error-message @@ -811,6 +813,19 @@ Print registers. Print the registers of the current frame." (print-registers cur)) +(define-meta-command (width repl #:optional x) + "width [X] +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)))) ;;; |