Formatting text: settings by parameterize around show, or with-fmt*

The Settings section says where a parameterize of a setting works: around
show, not around the code that builds a block. For part of an output it
shows with-fmt*, which binds several settings as parameterize does.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-opus-5-5)

Co-Authored-By: eca-agent <git@eca.dev>
This commit is contained in:
Linus Björnstam 2026-10-20 12:20:48 +02:00
parent 5bc42069cd
commit 4f8da92dc2

View file

@ -893,14 +893,25 @@ The rows can be spliced, @code{(rows ,scores)}, from a @code{(Vec (Vec TableCell
@subsubsection{Settings}
The pad character, the right margin, the ellipsis and the number formats are parameters. @code{with-fmt} binds one around some blocks while they run, and @code{with-pad} is @code{with-fmt} for @code{current-pad}. Settings nest:
The pad character, the right margin, the ellipsis and the number formats are parameters. For a whole output, set them with @code{parameterize} around the @code{show}:
@codeblock[#:lang "bjolang"]|{
(show [(with-fmt current-comma 3
(with-fmt current-comma-sep #\space
(with-fmt current-decimal-sep #\,
(numeric 1234567.5))))
nl])
(parameterize ((current-width 20))
(show (wrapped "Bjolang lays text out with blocks, and blocks nest.")))
;; Bjolang lays text
;; out with blocks, and
;; blocks nest.
}|
A block reads its settings when it runs, which is in @code{show}, not when it is built. So the @code{parameterize} must be around the @code{show}: around the code that builds the block, it has ended before the block runs, and does nothing. @code{(show (parameterize ((current-width 20)) (wrapped text)))} wraps at the default width, 78.
For part of an output, such as one paragraph, one cell or the numbers of one column, put the setting in the layout. @code{with-fmt} binds one setting around a block while it runs, @code{with-fmt*} binds several, written as @code{parameterize} is, and @code{with-pad} is @code{with-fmt} for @code{current-pad}:
@codeblock[#:lang "bjolang"]|{
(show (with-fmt* ((current-comma 3)
(current-comma-sep #\space)
(current-decimal-sep #\,))
(numeric 1234567.5) nl))
;; 1 234 567,5
}|