write-contents-functions is better than before-save-hook