write-file-functions

write-file-functions is a variable defined in `files.el'.
Its value is
nil

  • This variable's value is permanent if it is given a local binding.
  • This variable may be risky if used as a file-local variable.

Documentation:
List of functions to be called before writing out a buffer to a file.
If one of them returns non-nil, the file is considered already written
and the rest are not called.
These hooks are considered to pertain to the visited file.
So any buffer-local binding of this variable is discarded if you change
the visited file name with M-x set-visited-file-name, but not when you
change the major mode.

This hook is not run if any of the functions in
`write-contents-functions' returns non-nil. Both hooks pertain
to how to save a buffer to file, for instance, choosing a suitable
coding system and setting mode bits. (See Info
node `(elisp)Saving Buffers'.) To perform various checks or
updates before the buffer is saved, use `before-save-hook'.