Output is diverted using divert
:
divert(opt number)
where number is the diversion to be used. If number is left out, it is assumed to be zero.
The expansion of divert
is void.
When all the m4
input will have been processed, all existing
diversions are automatically undiverted, in numerical order.
divert(1) This text is diverted. divert => This text is not diverted. =>This text is not diverted. ^D => =>This text is diverted.
Several calls of divert
with the same argument do not overwrite
the previous diverted text, but append to it.
If output is diverted to a non-existent diversion, it is simply discarded. This can be used to suppress unwanted output. A common example of unwanted output is the trailing newlines after macro definitions. Here is how to avoid them.
divert(-1) define(`foo', `Macro `foo'.') define(`bar', `Macro `bar'.') divert =>
This is a common programming idiom in m4
.
Go to the first, previous, next, last section, table of contents.