Diversions are a facility in M4 for diverting text from the input stream
into a holding buffer. There is a large number of diversion buffers in
GNU M4, limited only by available memory. Text can be diverted
into any one of these buffers and then `undiverted' back to the output
(diversion number 0) at a later stage.
Text is diverted and undiverted using the
undivert macros. They expand to the empty string, with the side
effect of setting the diversion. Here is an illustrative example:
This goes at the end.
This goes at the beginning.
=>This goes at the beginning.
=>This goes at the end.
It is unlikely that you will want to use diversions in your own macros,
and it is difficult to do reliably without understanding the internals
of Autoconf. However, it is interesting to note that this is how
autoconf generates fragments of shell code on-the-fly that
must precede shell code at the current point in the `configure'