I use emacs, slime, and sbcl. When I'm thrown into debugger when condition occurs, how do I limit the size of the output? I have figured out *print-length*
and *print-level*
, but what to do about long strings or strings with many lines? Say,
(defun monkeys (length)
"Generate a random string"
(with-output-to-string (out)
(dotimes (i length)
(write-char
(code-char
(let ((c (random 27)))
(if (zerop c)
(if (zerop (random 5)) 10 32)
(+ 95 c)))) out))))
(1+ (monkeys 10000)) ; drop into debugger
Long story short, on sbcl *print-vector-length*
can be used. From the SBCL source code:
(defparameter *print-vector-length* nil
"Like *PRINT-LENGTH* but works on strings and bit-vectors.
Does not affect the cases that are already controlled by *PRINT-LENGTH*")
Long story long, I somehow never thought to look at the source code. However, thanks to the answer from @tfb, I at least had a starting point. So I went on to read about the pretty printer's dispatch table, and, just to see how dispatch functions look, I checked what the default dispatch function for 'string
is:
(pprint-dispatch 'string)
That gives #<FUNCTION SB-KERNEL:OUTPUT-UGLY-OBJECT>
. I searched for it in the SBCL source code and found the necessary parameter along the way.