mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 01:00:20 +02:00
add ~@y truncated printing directive to format
* doc/ref/misc-modules.texi (Formatted Output): Add documentation for the new ~@y format directive. (Pretty Printing): Add documentation for truncated-write. * module/ice-9/format.scm (format): Add ~@y, for doing a truncated print. Also, allow both ~y variants to take a width parameter.
This commit is contained in:
parent
8c6eea2f1a
commit
b8596c08ac
2 changed files with 89 additions and 9 deletions
|
@ -13,7 +13,7 @@
|
|||
|
||||
(define-module (ice-9 format)
|
||||
:use-module (ice-9 and-let-star)
|
||||
:autoload (ice-9 pretty-print) (pretty-print)
|
||||
:autoload (ice-9 pretty-print) (pretty-print truncated-print)
|
||||
:replace (format)
|
||||
:export (format:symbol-case-conv
|
||||
format:iobj-case-conv
|
||||
|
@ -482,10 +482,23 @@
|
|||
((#\T) ; Tabulate
|
||||
(format:tabulate modifier params)
|
||||
(anychar-dispatch))
|
||||
((#\Y) ; Pretty-print
|
||||
(pretty-print (next-arg) format:port)
|
||||
(set! format:output-col 0)
|
||||
(anychar-dispatch))
|
||||
((#\Y) ; Structured print
|
||||
(let ((width (if (one-positive-integer? params)
|
||||
(car params)
|
||||
79)))
|
||||
(case modifier
|
||||
((colon colon-at)
|
||||
(format:error "illegal modifier in ~~?"))
|
||||
((at)
|
||||
(format:out-str
|
||||
(with-output-to-string
|
||||
(lambda ()
|
||||
(truncated-print (next-arg) #:width width)))))
|
||||
(else
|
||||
(pretty-print (next-arg) format:port
|
||||
#:width width)
|
||||
(set! format:output-col 0))))
|
||||
(anychar-dispatch))
|
||||
((#\? #\K) ; Indirection (is "~K" in T-Scheme)
|
||||
(cond
|
||||
((memq modifier '(colon colon-at))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue