On the GNU m4 home page it says to send suggestions for m4 extensions here.
My suggestion is to be able to undivert to a file. So, divert(1) here is some text divert(0) undivertf(1, `filename.txt') saves the diversion to the stated file, replacing it. Additionally, undivertf(1, `dir1/dir2/filename.txt') would create dir1 and dir1/dir2 if they do not already exist. I currently have obtained this function by programming a filter on the back end of m4, but it would be nice to have it in m4 proper.
