manpagez: man pages & more
info m4
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.4 Discarding diverted text

Often it is not known, when output is diverted, whether the diverted text is actually needed. Since all non-empty diversion are brought back on the main output stream when the end of input is seen, a method of discarding a diversion is needed. If all diversions should be discarded, the easiest is to end the input to m4 with ‘divert(`-1')’ followed by an explicit ‘undivert’:

Diversion one: divnum
Diversion two: divnum

No output is produced at all.

Clearing selected diversions can be done with the following macro:

Composite: cleardivert ([diversions…]

Discard the contents of each of the listed numeric diversions.

`pushdef(`_n', divnum)divert(`-1')undivert($@)divert(_n)popdef(`_n')')

It is called just like undivert, but the effect is to clear the diversions, given by the arguments. (This macro has a nasty bug! You should try to see if you can find it and correct it; or see section Answers).

This document was generated on September 29, 2013 using texi2html 5.0.

© 2000-2017
Individual documents may contain additional copyright information.