diff options
-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)))) ;;; |