There are occasions where the printer needs to save the active config to the config file. One of which is after a new bed mesh has been created. Unfortunately, a side-effect of saving is a restart of Klipper.
If the bed mesh is created as part of the print start macro (e.g. by using DutchDude's automatic bed selection) this aborts the print requiring the user to restart the print again.
A way to save the newly created mesh is to defer the saving action to after the print. For various reasons ond might not want to restart the printer unconditionally. The below functions do a conditional save where the SAVE_IF_SET macro saves the configfile only if the SAVE_AT_END macro has been called since the printer's startup.
This macro contains a variable that stores the save flag which is unset by default and set by executing the macro.