Variable: write-contents-functions

write-contents-functions is a buffer-local variable defined in files.el.gz.

Documentation

List of functions to be called before writing out a buffer to a file.

Used only by save-buffer. If one of them returns non-nil, the file is considered already written and the rest are not called and neither are the functions in write-file-functions. This hook can thus be used to create save behavior for buffers that are not visiting a file at all.

This variable is meant to be used for hooks that pertain to the buffer's contents, not to the particular visited file; thus, set-visited-file-name does not clear this variable; but changing the major mode does clear it.

For hooks that _do_ pertain to the particular visited file, use write-file-functions. Both this variable and write-file-functions relate to how a buffer is saved to file. To perform various checks or updates before the buffer is saved, use before-save-hook.

View in manual

Probably introduced at or before Emacs version 22.1.

Aliases

write-contents-hooks (obsolete since 22.1)

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defvar-local write-contents-functions nil
  "List of functions to be called before writing out a buffer to a file.

Used only by `save-buffer'.  If one of them returns non-nil, the
file is considered already written and the rest are not called
and neither are the functions in `write-file-functions'.  This
hook can thus be used to create save behavior for buffers that
are not visiting a file at all.

This variable is meant to be used for hooks that pertain to the
buffer's contents, not to the particular visited file; thus,
`set-visited-file-name' does not clear this variable; but changing the
major mode does clear it.

For hooks that _do_ pertain to the particular visited file, use
`write-file-functions'.  Both this variable and
`write-file-functions' relate to how a buffer is saved to file.
To perform various checks or updates before the buffer is saved,
use `before-save-hook'.")