1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 03:30:27 +02:00

~:@y allows for truncation to an absolute maximum width

* module/ice-9/format.scm (format): Allow ~:@y to interpret the width as
  the maximum width, inclusive of whatever else has already been output.
* doc/ref/misc-modules.texi (Formatted Output): Document this.
This commit is contained in:
Andy Wingo 2009-12-29 21:15:08 +01:00
parent 2d8c757cf1
commit 9274c3dd40
2 changed files with 18 additions and 3 deletions

View file

@ -648,6 +648,11 @@ necessary.
within @var{width} columns (79 by default), on a single line. The
output will be truncated if necessary.
@nicode{~:@@y} is like @nicode{~@@y}, except the @var{width} parameter
is interpreted to be the maximum column to which to output. That is to
say, if you are at column 10, and @nicode{~60:@@y} is seen, the datum
will be truncated to 50 columns.
@item @nicode{~?}
@itemx @nicode{~k}
Sub-format. No parameters.

View file

@ -487,13 +487,23 @@
(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)))))
(truncated-print (next-arg)
#:width width)))))
((colon-at)
(format:out-str
(with-output-to-string
(lambda ()
(truncated-print (next-arg)
#:width
(max (- width
format:output-col)
1))))))
((colon)
(format:error "illegal modifier in ~~?"))
(else
(pretty-print (next-arg) format:port
#:width width)