aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2023-03-23 17:09:52 +0100
committerMichael Albinus2023-03-23 17:09:52 +0100
commitb19d040a4fe709b032143d8e569690073befabdf (patch)
treeacb7a74cd70f241da95745c068ce7045e797edda
parent117a29fd1889591d01e1bb5ede4eec9526a482ad (diff)
downloademacs-b19d040a4fe709b032143d8e569690073befabdf.tar.gz
emacs-b19d040a4fe709b032143d8e569690073befabdf.zip
New user option remote-file-name-inhibit-auto-save
* doc/misc/tramp.texi (Auto-save File Lock and Backup): Mention remote-file-name-inhibit-auto-save. (Frequently Asked Questions): Describe, how to suppress auto-save. * etc/NEWS: Add remote-file-name-inhibit-auto-save. * lisp/simple.el (remote-file-name-inhibit-auto-save): New defcustom. (auto-save-mode): Handle it. (Bug#62260) * lisp/net/tramp-integration.el (tramp-set-connection-local-variables-for-buffer): Declare. (find-file-hook): Add `tramp-set-connection-local-variables-for-buffer'.
-rw-r--r--doc/misc/tramp.texi36
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/net/tramp-integration.el11
-rw-r--r--lisp/simple.el10
4 files changed, 61 insertions, 1 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 6f14fc875f4..5d6def75f2f 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -3190,6 +3190,11 @@ auto-saved files to the same directory as the original file.
3190Alternatively, set the user option @code{tramp-auto-save-directory} 3190Alternatively, set the user option @code{tramp-auto-save-directory}
3191to direct all auto saves to that location. 3191to direct all auto saves to that location.
3192 3192
3193@c Since Emacs 30.
3194@vindex remote-file-name-inhibit-auto-save
3195If you want to suppress auto-saving of remote files at all, set user
3196option @code{remote-file-name-inhibit-auto-save} to non-@code{nil}.
3197
3193@c Since Emacs 29. 3198@c Since Emacs 29.
3194@vindex remote-file-name-inhibit-auto-save-visited 3199@vindex remote-file-name-inhibit-auto-save-visited
3195An alternative to @code{auto-save-mode} is 3200An alternative to @code{auto-save-mode} is
@@ -4907,6 +4912,36 @@ Disable file locks. Set @code{remote-file-name-inhibit-locks} to
4907the same remote file. 4912the same remote file.
4908 4913
4909@item 4914@item
4915@vindex remote-file-name-inhibit-auto-save
4916Keep auto-save files local. This is already the default configuration
4917in Emacs, don't change it. If you want to disable auto-saving for
4918remote files at all, set @code{remote-file-name-inhibit-auto-save} to
4919@code{t}, but think about the consequences!
4920
4921If you want to disable auto-saving just for selected connections, for
4922example due to security considerations, use connection-local variables
4923in order to set @code{buffer-auto-save-file-name}. If you, for
4924example, want to disable auto-saving for all @option{sudo}
4925connections, apply the following code.
4926@ifinfo
4927@xref{Connection Variables, , , emacs}.
4928@end ifinfo
4929
4930@lisp
4931@group
4932(connection-local-set-profile-variables
4933 'my-auto-save-profile
4934 '((buffer-auto-save-file-name . nil)))
4935@end group
4936
4937@group
4938(connection-local-set-profiles
4939 '(:application tramp :protocol "sudo")
4940 'my-auto-save-profile)
4941@end group
4942@end lisp
4943
4944@item
4910Disable excessive traces. Set @code{tramp-verbose} to 3 or lower, 4945Disable excessive traces. Set @code{tramp-verbose} to 3 or lower,
4911default being 3. Increase trace levels temporarily when hunting for 4946default being 3. Increase trace levels temporarily when hunting for
4912bugs. 4947bugs.
@@ -5220,6 +5255,7 @@ HISTFILE=/dev/null
5220@item 5255@item
5221Where are remote files trashed to? 5256Where are remote files trashed to?
5222 5257
5258@vindex remote-file-name-inhibit-delete-by-moving-to-trash
5223Emacs can trash file instead of deleting 5259Emacs can trash file instead of deleting
5224@ifinfo 5260@ifinfo
5225them, @ref{Misc File Ops, Trashing , , emacs}. 5261them, @ref{Misc File Ops, Trashing , , emacs}.
diff --git a/etc/NEWS b/etc/NEWS
index 80413c00965..ffce2baf2d0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -50,6 +50,11 @@ as it has in batch mode since Emacs 24.
50When non-nil, this option suppresses moving remote files to the local 50When non-nil, this option suppresses moving remote files to the local
51trash when deleting. Default is nil. 51trash when deleting. Default is nil.
52 52
53---
54** New user option 'remote-file-name-inhibit-auto-save'.
55If this user option is non-nil, 'auto-save-mode' will not auto-save
56remote buffers. The default is nil.
57
53+++ 58+++
54** New user option 'yes-or-no-prompt'. 59** New user option 'yes-or-no-prompt'.
55This allows the user to customize the prompt that is appended by 60This allows the user to customize the prompt that is appended by
diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el
index 5b3259eab03..d7fcd8afefa 100644
--- a/lisp/net/tramp-integration.el
+++ b/lisp/net/tramp-integration.el
@@ -42,9 +42,10 @@
42(declare-function shortdoc-add-function "shortdoc") 42(declare-function shortdoc-add-function "shortdoc")
43(declare-function tramp-dissect-file-name "tramp") 43(declare-function tramp-dissect-file-name "tramp")
44(declare-function tramp-file-name-equal-p "tramp") 44(declare-function tramp-file-name-equal-p "tramp")
45(declare-function tramp-tramp-file-p "tramp")
46(declare-function tramp-rename-files "tramp-cmds") 45(declare-function tramp-rename-files "tramp-cmds")
47(declare-function tramp-rename-these-files "tramp-cmds") 46(declare-function tramp-rename-these-files "tramp-cmds")
47(declare-function tramp-set-connection-local-variables-for-buffer "tramp")
48(declare-function tramp-tramp-file-p "tramp")
48(defvar eshell-path-env) 49(defvar eshell-path-env)
49(defvar ido-read-file-name-non-ido) 50(defvar ido-read-file-name-non-ido)
50(defvar info-lookup-alist) 51(defvar info-lookup-alist)
@@ -549,6 +550,14 @@ See `tramp-process-attributes-ps-format'.")
549 '(:application tramp :machine "localhost") 550 '(:application tramp :machine "localhost")
550 local-profile)) 551 local-profile))
551 552
553;; Set connection-local variables for buffers visiting a file.
554
555(add-hook 'find-file-hook #'tramp-set-connection-local-variables-for-buffer -50)
556(add-hook 'tramp-unload-hook
557 (lambda ()
558 (remove-hook
559 'find-file-hook #'tramp-set-connection-local-variables-for-buffer)))
560
552(add-hook 'tramp-unload-hook 561(add-hook 'tramp-unload-hook
553 (lambda () (unload-feature 'tramp-integration 'force))) 562 (lambda () (unload-feature 'tramp-integration 'force)))
554 563
diff --git a/lisp/simple.el b/lisp/simple.el
index 80c75d4d7c3..1447c7e53ff 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -9108,6 +9108,13 @@ presented."
9108 "Toggle buffer size display in the mode line (Size Indication mode)." 9108 "Toggle buffer size display in the mode line (Size Indication mode)."
9109 :global t :group 'mode-line) 9109 :global t :group 'mode-line)
9110 9110
9111(defcustom remote-file-name-inhibit-auto-save nil
9112 "When nil, `auto-save-mode' will auto-save remote files.
9113Any other value means that it will not."
9114 :group 'auto-save
9115 :type 'boolean
9116 :version "30.1")
9117
9111(define-minor-mode auto-save-mode 9118(define-minor-mode auto-save-mode
9112 "Toggle auto-saving in the current buffer (Auto Save mode). 9119 "Toggle auto-saving in the current buffer (Auto Save mode).
9113 9120
@@ -9130,6 +9137,9 @@ For more details, see Info node `(emacs) Auto Save'."
9130 (setq buffer-auto-save-file-name 9137 (setq buffer-auto-save-file-name
9131 (cond 9138 (cond
9132 ((null val) nil) 9139 ((null val) nil)
9140 ((and buffer-file-name remote-file-name-inhibit-auto-save
9141 (file-remote-p buffer-file-name))
9142 nil)
9133 ((and buffer-file-name auto-save-visited-file-name 9143 ((and buffer-file-name auto-save-visited-file-name
9134 (not buffer-read-only)) 9144 (not buffer-read-only))
9135 buffer-file-name) 9145 buffer-file-name)