In m4, is it possible to expand a macro and to immediately put it in quotes? That is, instead of
define(HELLO, `Hello!')dnl
define(MACRO, `HELLO')dnl
MACRO
expanding to Hello!, I would love to have some function qexpand, for example, such that
define(HELLO, `Hello!')dnl
define(MACRO, `HELLO')dnl
qexpand(`MACRO')
expands to HELLO. But any other line after the first two that expands MACRO into a string would do as well, of course.
Background. I want to operate substitutions on the expansion of a macro using patsubst, say substituting commas in it. Unfortunately
define(`MACRO',`x,y,z')dnl
patsubst(`MACRO',`,',`.')
yields x,y,z, as the substitution is performed on the string MACRO. But if the expansion of the macro contains commas, the variant
define(`MACRO',`x,y,z')dnl
patsubst(MACRO,`,',`.')
has the second line first expand to patsubst(x,y,z,`,',`.'), giving the error Warning: excess arguments to builtin `patsubst' ignored. The possibility of expanding a macro into quotes would solve this.