> The point is that text goes into a diversion only when _you are not doing > argument collection_ - in other words, the macro call must be expanded at > the outermost level. Any macro that potentially changes the current > diversion must be quoted, rather than expanded in advance, when handed as > an argument to another macro; otherwise, the text output while the > diversion change is in effect doesn't go to the changed diversion, but to > the argument collection.
Yeah, that's the similar testcase I got: m4_init m4_define([FROBIT], [m4_divert_text([6], [in diversion _m4_divert_diversion])$1]) m4_define([SHOWIT], [$[]1 is $1]) m4_define([TEXT], [FROBIT(text)]) m4_divert_pop([KILL]) m4_divert_push([1000])dnl SHOWIT([TEXT]) and that's also the reason why the original testcase was failing. Paolo