I use [c]M28[/c] and [c]M29[/c] for this in my 'Load Filament' scripts:
M28 /sys/current_material.g ; open current_material.g for writing
M207 S6.0 F7800 Z0.2 R0.1
G10 P0 R150 S220
M29 ; close current_material.g
And in my [c]config.g[/c] I have this line: [c]M98 P/sys/current_material.g[/c]
Every line between [c]M28[/c] and [c]M29[/c] is written into [c]/sys/current_material.g[/c] which in turn is then loaded when the printer is starting up. You could even write your whole [c]config.g[/c] with a macro. But beware - comments are ignored, ';'s are stripped and the whole line ends up in the file…