[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Allow inhibiting 'auto-save-visited-mode' on a per-buffer basis.
From: |
Philipp Stephani |
Subject: |
[PATCH] Allow inhibiting 'auto-save-visited-mode' on a per-buffer basis. |
Date: |
Wed, 1 Apr 2020 19:57:36 +0200 |
* lisp/files.el (auto-save-visited-inhibit): New buffer-local
variable.
(auto-save-visited-mode): Use it.
* etc/NEWS: Document new variable.
---
etc/NEWS | 4 ++++
lisp/files.el | 8 +++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/etc/NEWS b/etc/NEWS
index 765a923bf7..659695b40f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -93,6 +93,10 @@ line numbers that were previously jumped to.
** When 'suggest-key-bindings' is non-nil, the completion list of 'M-x'
shows equivalent key bindings for all commands that have them.
++++
+** Autosaving via 'auto-save-visited-mode' can now be inhibited using
+the buffer-local variable 'auto-save-visited-inhibit'.
+
* Changes in Specialized Modes and Packages in Emacs 28.1
diff --git a/lisp/files.el b/lisp/files.el
index 55a0958f54..f3ea1d083f 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -425,12 +425,17 @@ auto-save-visited-interval
(when auto-save--timer
(timer-set-idle-time auto-save--timer value :repeat))))
+(defvar-local auto-save-visited-inhibit nil
+ "If non-nil, ignore this buffer for `auto-save-visited-mode'.")
+
(define-minor-mode auto-save-visited-mode
"Toggle automatic saving to file-visiting buffers on or off.
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.
+Buffers in which the variable `auto-save-visted-mode' is non-nil
+are ignored."
:group 'auto-save
:global t
(when auto-save--timer (cancel-timer auto-save--timer))
@@ -441,6 +446,7 @@ auto-save-visited-mode
#'save-some-buffers :no-prompt
(lambda ()
(and buffer-file-name
+ (not auto-save-visited-inhibit)
(not (and buffer-auto-save-file-name
auto-save-visited-file-name))))))))
--
2.26.0.rc2.310.g2932bb562d-goog
- [PATCH] Allow inhibiting 'auto-save-visited-mode' on a per-buffer basis.,
Philipp Stephani <=
Re: [PATCH] Allow inhibiting 'auto-save-visited-mode' on a per-buffer basis., Eli Zaretskii, 2020/04/02