On 03/14/2015 05:01 PM, Matěj Týč wrote:
Hello again,
In my m4 project where I use autom4te and m4sugar (for those who are
curious - https://github.com/matejak/d8 ),
in order to be able to output anything, one has to call
m4_divert_push(1) (or something similar) at certain point. However,
every time I do that, I get the
warning: prefer named diversions
warning. I know that I can use m4_divert_push(KILL) in place of
m4_divert_push(0), but a trivial diversion e.g. for stdout is not
available (or documented). There is also a lack of documentation on how
to register a named diversion, using a macro instead of a number isn't
the right way how to make a named diversion.
Do you have any solution to this in mind? Telling autom4te to suppress
warnings doesn't feel right.
According to the manual, m4sugar defines KILL and GROW as named
diversions; m4sh (if you use AS_INIT instead of m4_init) also adds
BINSH, several HEADER-*, M4SH-SANITIZE, M4SH-INIT, and BODY. That is,
if you are using autom4te to generate a shell script, then you
eventually want to m4_divert_push([BODY]) (although you get it free by
using AS_INIT).
As for creating new named diversions, they are not documented in the
manual, but you can learn about them in the m4sugar source code
(basically, m4_define([_m4_divert(NAME)], NUMBER) will define
m4_divert_push(NAME) to use that diversion number).