From 4f8da92dc22e4d9f47bb94eb1231a29dbba685c7a79ad653225c36562ebb57a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Bj=C3=B6rnstam?= Date: Tue, 20 Oct 2026 12:20:48 +0200 Subject: [PATCH] Formatting text: settings by parameterize around show, or with-fmt* MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- _02_.Writing-programs.sz | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/_02_.Writing-programs.sz b/_02_.Writing-programs.sz index 292041f..9677a5d 100644 --- a/_02_.Writing-programs.sz +++ b/_02_.Writing-programs.sz @@ -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 }|