To perform various checks or
updates before the buffer is saved, use ‘before-save-hook’.
你用错 hook 了,write-file-functions 的 doc string 有如下。
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’.)