Next: , Previous: , Up: Traps   [Contents][Index]


5.24.5 Leading Spaces Traps

Request: .lsm macro
Register: \n[lsn]
Register: \n[lss]

Set a leading spaces trap. gtroff executes macro when it encounters leading spaces in an input line; the implicit line break that normally happens in this case is suppressed. A line consisting of spaces only, however, is treated as an empty line, possibly subject to an empty line macro set with the blm request.

Leading spaces are removed from the input line before calling the leading spaces macro. The number of removed spaces is stored in register lsn; the horizontal space that would be emitted if there was no leading space macro is stored in register lss. Note that lsn and lss are available even if no leading space macro has been set.

The first thing a leading space macro sees is a token. However, some escapes like \f or \m are handled on the fly (see Gtroff Internals, for a complete list) without creating a token at all. Consider that a line starts with two spaces followed by \fIfoo. While skipping the spaces \fI is handled too so that groff’s current font is properly set to ‘I’, but the leading space macro only sees foo, without the preceding \fI. If the macro should see the font escape you have to ‘protect’ it with something that creates a token, for example with \&\fIfoo.