From f8e99938ec41a9af8d42b2ed78af1370fc2c1bc2 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Wed, 1 Apr 2020 19:54:01 +0200 Subject: [PATCH] Allow inhibiting 'auto-save-visited-mode' on a per-buffer basis. At least for me, 'auto-save-visited-mode' is very slow and blocks user interaction for files visited over TRAMP. Therefore, I'd like a mechanism to disable it for some buffers (namely, those visiting remote files). * (auto-save-visited-mode): Document that 'auto-save-visited-mode' can be set to nil buffer-locally. * etc/NEWS: Document new behavior. --- etc/NEWS | 3 +++ lisp/files.el | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index 4bc00cc3375..e09f32a7c35 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -98,6 +98,9 @@ shows equivalent key bindings for all commands that have them. 'gomoku-move-sw' and 'gomoku-move-ne' now work correctly, and horizontal movements now stop at the edge of the board. +** Autosaving via 'auto-save-visited-mode' can now be inhibited by +setting the variable 'auto-save-visited-mode' buffer-locally to nil. + * Changes in Specialized Modes and Packages in Emacs 28.1 diff --git a/lisp/files.el b/lisp/files.el index dba704f7a4b..cb370476496 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -430,7 +430,13 @@ idle for `auto-save-visited-interval' seconds." Unlike `auto-save-mode', this mode will auto-save buffer contents to the visited files directly and will also run all save-related -hooks. See Info node `Saving' for details of the save process." +hooks. See Info node `Saving' for details of the save process. + +You can also set the buffer-local value of the variable +`auto-save-visted-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." :group 'auto-save :global t (when auto-save--timer (cancel-timer auto-save--timer)) @@ -441,6 +447,7 @@ hooks. See Info node `Saving' for details of the save process." #'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)))))))) -- 2.39.5