Function: auto-save-visited-mode
auto-save-visited-mode is an interactive and byte-compiled function
defined in files.el.gz.
Signature
(auto-save-visited-mode &optional ARG)
Documentation
Toggle automatic saving of file-visiting buffers to their files.
When this mode is enabled, file-visiting buffers are automatically
saved to their files. This is in contrast to auto-save-mode, which
auto-saves those buffers to a separate file, leaving the original
file intact. See Info node (emacs)Saving for details of the save process.
The user option auto-save-visited-interval controls how often to
auto-save a buffer into its visited file.
You can use auto-save-visited-predicate to control which
buffers are saved.
You can also set the buffer-local value of the variable
auto-save-visited-mode(var)/auto-save-visited-mode(fun) to nil. A buffer where the buffer-local
value of this variable is nil is ignored for the purpose of
auto-save-visited-mode(var)/auto-save-visited-mode(fun), even if auto-save-visited-mode(var)/auto-save-visited-mode(fun) is
enabled.
For more details, see Info node (emacs) Auto Save Files.
This is a global minor mode. If called interactively, toggle the
Auto-Save-Visited mode mode. If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.
If called from Lisp, toggle the mode if ARG is toggle. Enable the
mode if ARG is nil, omitted, or is a positive number. Disable the mode
if ARG is a negative number.
To check whether the minor mode is enabled in the current buffer,
evaluate (default-value \=auto-save-visited-mode)'.
The mode's hook is called both when the mode is enabled and when it is disabled.
Probably introduced at or before Emacs version 26.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/files.el.gz
(define-minor-mode auto-save-visited-mode
"Toggle automatic saving of file-visiting buffers to their files.
When this mode is enabled, file-visiting buffers are automatically
saved to their files. This is in contrast to `auto-save-mode', which
auto-saves those buffers to a separate file, leaving the original
file intact. See Info node `Saving' for details of the save process.
The user option `auto-save-visited-interval' controls how often to
auto-save a buffer into its visited file.
You can use `auto-save-visited-predicate' to control which
buffers are saved.
You can also set the buffer-local value of the variable
`auto-save-visited-mode' to nil. A buffer where the buffer-local
value of this variable is nil is ignored for the purpose of
`auto-save-visited-mode', even if `auto-save-visited-mode' is
enabled.
For more details, see Info node `(emacs) Auto Save Files'."
:group 'auto-save
:global t
(when auto-save--timer (cancel-timer auto-save--timer))
(setq auto-save--timer
(when auto-save-visited-mode
(run-with-idle-timer
auto-save-visited-interval :repeat
#'save-some-buffers :no-prompt
(lambda ()
(and buffer-file-name
auto-save-visited-mode
(not (and buffer-auto-save-file-name
auto-save-visited-file-name))
(or (not (file-remote-p buffer-file-name))
(not remote-file-name-inhibit-auto-save-visited))
(or (not (functionp auto-save-visited-predicate))
(funcall auto-save-visited-predicate))))))))