Next: , Previous: , Up: formations   [Index]


52.10 Escape sequences for columns and indentation

Format Escape Sequence: ~y

Pretty print. No parameters.

Output an argument with pretty-print.

Format Escape Sequence: ~_

Space character. Parameter: N.

Output a space character, or N spaces if a parameter is given.

With a variable parameter this is one way to insert runtime calculated padding (~t or the various field widths can do similar things).

(format "~_foo" 4)      ⇒ " foo"
(format "~3_foo" 4)     ⇒ "   foo"
Format Escape Sequence: ~t

Advance to a column position. Parameters: colnum, colinc, padchar.

Output padchar (space by default) to move to the given colnum column. The start of the line is column 0, the default for colnum is 1.

(format "~tX")          ⇒ " X"
(format "~0tX")         ⇒ "X"
(format "~1tX")         ⇒ " X"
(format "~2tX")         ⇒ "  X"
(format "~3tX")         ⇒ "   X"

(format "~,,'.tX")      ⇒ ".X"
(format "~0,,'.tX")     ⇒ "X"
(format "~1,,'.tX")     ⇒ ".X"
(format "~2,,'.tX")     ⇒ "..X"
(format "~3,,'.tX")     ⇒ "...X"

If the current column is already past colnum, then the move is to column colnum + N * colinc for the smallest N which makes that value greater than or equal to the current column. The default colinc is 1 (which means no further move). In the following examples ~t is found when the next character should be output at column 4:

;; colnum + N * colinc = 0+N*5 = 0+1*5 = 5
(format "abcd~0,5,'.tX")        ⇒ "abcd.X"
;;;                                 0123456789

;; colnum + N * colinc = 1+N*5 = 1+1*5 = 6
(format "abcd~1,5,'.tX")        ⇒ "abcd..X"
;;;                                 0123456789

;; colnum + N * colinc = 2+N*5 = 2+1*5 = 7
(format "abcd~2,5,'.tX")        ⇒ "abcd...X"
;;;                                 0123456789

;; colnum + N * colinc = 3+N*5 = 3+1*5 = 8
(format "abcd~3,5,'.tX")        ⇒ "abcd....X"
;;;                                 0123456789

~@t takes colnum as an offset from the current column. colnum pad characters are output, then further padding to make the current column a multiple of colinc, if it isn’t already so.

(format #f "a~3,5'*@tx") ⇒ "a****x"
Format Escape Sequence: ~/

Tab character. Parameter: N.

Output a tab character, or N tabs if a parameter is given.

(format "A~/Z")         ⇒ "A\tZ"
(format "A~3/Z")        ⇒ "A\t\t\tZ"

Next: , Previous: , Up: formations   [Index]