unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: emacs-devel@gnu.org
Cc: Philipp Stephani <phst@google.com>
Subject: [PATCH] Allow inhibiting 'auto-save-visited-mode' on a per-buffer basis.
Date: Wed,  1 Apr 2020 19:57:36 +0200	[thread overview]
Message-ID: <20200401175736.203124-1-phst@google.com> (raw)

* 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'.
+
 \f
 * 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




             reply	other threads:[~2020-04-01 17:57 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-01 17:57 Philipp Stephani [this message]
2020-04-02  9:24 ` [PATCH] Allow inhibiting 'auto-save-visited-mode' on a per-buffer basis Robert Pluim
2020-04-02  9:40   ` Philipp Stephani
2020-04-02  9:47     ` Robert Pluim
2020-04-02  9:59       ` Štěpán Němec
2020-04-02 11:15         ` Philipp Stephani
2020-04-02 11:27           ` Štěpán Němec
2020-04-02 13:38 ` Eli Zaretskii
2020-04-02 15:22   ` Stefan Monnier
2020-04-05  9:50     ` Philipp Stephani
2020-04-05 14:18       ` Stefan Monnier
2020-04-05 15:51         ` Philipp Stephani
2020-04-05 18:49           ` Stefan Monnier
2020-04-05 19:58             ` Philipp Stephani
2020-04-08 11:43               ` Philipp Stephani
2020-04-08 12:03                 ` Eli Zaretskii
2020-04-08 12:19                   ` Philipp Stephani
2020-04-08 13:07                     ` Eli Zaretskii
2020-04-08 14:58                 ` Stefan Monnier
2020-04-11 16:57                   ` Philipp Stephani
2020-04-11 17:11                     ` Stefan Monnier
2020-05-25 19:16                       ` Philipp Stephani
2020-04-05  9:52   ` Philipp Stephani
2020-04-05 13:11     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200401175736.203124-1-phst@google.com \
    --to=p.stephani2@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=phst@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).