summaryrefslogtreecommitdiffstats
path: root/pp.scm
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:28 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:28 -0800
commit87b82b5822ca54228cfa6df29be3ad9d4bc47d16 (patch)
tree1eb4f87abd38bea56e08335d939e8171d5e7bfc7 /pp.scm
parentbd9733926076885e3417b74de76e4c9c7bc56254 (diff)
downloadslib-87b82b5822ca54228cfa6df29be3ad9d4bc47d16.tar.gz
slib-87b82b5822ca54228cfa6df29be3ad9d4bc47d16.zip
Import Upstream version 2d2upstream/2d2
Diffstat (limited to 'pp.scm')
-rw-r--r--pp.scm15
1 files changed, 9 insertions, 6 deletions
diff --git a/pp.scm b/pp.scm
index 1dbada0..feb90a8 100644
--- a/pp.scm
+++ b/pp.scm
@@ -1,12 +1,15 @@
-;"pp.scm" Pretty-print
-
+;"pp.scm" Pretty-Print
(require 'generic-write)
-; (pretty-print obj port) pretty prints 'obj' on 'port'. The current
-; output port is used if 'port' is not specified.
-
(define (pp:pretty-print obj . opt)
(let ((port (if (pair? opt) (car opt) (current-output-port))))
- (generic-write obj #f 79 (lambda (s) (display s port) #t))))
+ (generic-write obj #f (output-port-width port)
+ (lambda (s) (display s port) #t))))
+
+(define (pretty-print->string obj . width)
+ (define result '())
+ (generic-write obj #f (if (null? width) (output-port-width) (car width))
+ (lambda (str) (set! result (cons str result)) #t))
+ (reverse-string-append result))
(define pretty-print pp:pretty-print)