diff options
| author | Michael Albinus | 2023-03-23 17:09:52 +0100 |
|---|---|---|
| committer | Michael Albinus | 2023-03-23 17:09:52 +0100 |
| commit | b19d040a4fe709b032143d8e569690073befabdf (patch) | |
| tree | acb7a74cd70f241da95745c068ce7045e797edda | |
| parent | 117a29fd1889591d01e1bb5ede4eec9526a482ad (diff) | |
| download | emacs-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.texi | 36 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/net/tramp-integration.el | 11 | ||||
| -rw-r--r-- | lisp/simple.el | 10 |
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. | |||
| 3190 | Alternatively, set the user option @code{tramp-auto-save-directory} | 3190 | Alternatively, set the user option @code{tramp-auto-save-directory} |
| 3191 | to direct all auto saves to that location. | 3191 | to direct all auto saves to that location. |
| 3192 | 3192 | ||
| 3193 | @c Since Emacs 30. | ||
| 3194 | @vindex remote-file-name-inhibit-auto-save | ||
| 3195 | If you want to suppress auto-saving of remote files at all, set user | ||
| 3196 | option @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 |
| 3195 | An alternative to @code{auto-save-mode} is | 3200 | An alternative to @code{auto-save-mode} is |
| @@ -4907,6 +4912,36 @@ Disable file locks. Set @code{remote-file-name-inhibit-locks} to | |||
| 4907 | the same remote file. | 4912 | the same remote file. |
| 4908 | 4913 | ||
| 4909 | @item | 4914 | @item |
| 4915 | @vindex remote-file-name-inhibit-auto-save | ||
| 4916 | Keep auto-save files local. This is already the default configuration | ||
| 4917 | in Emacs, don't change it. If you want to disable auto-saving for | ||
| 4918 | remote files at all, set @code{remote-file-name-inhibit-auto-save} to | ||
| 4919 | @code{t}, but think about the consequences! | ||
| 4920 | |||
| 4921 | If you want to disable auto-saving just for selected connections, for | ||
| 4922 | example due to security considerations, use connection-local variables | ||
| 4923 | in order to set @code{buffer-auto-save-file-name}. If you, for | ||
| 4924 | example, want to disable auto-saving for all @option{sudo} | ||
| 4925 | connections, 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 | ||
| 4910 | Disable excessive traces. Set @code{tramp-verbose} to 3 or lower, | 4945 | Disable excessive traces. Set @code{tramp-verbose} to 3 or lower, |
| 4911 | default being 3. Increase trace levels temporarily when hunting for | 4946 | default being 3. Increase trace levels temporarily when hunting for |
| 4912 | bugs. | 4947 | bugs. |
| @@ -5220,6 +5255,7 @@ HISTFILE=/dev/null | |||
| 5220 | @item | 5255 | @item |
| 5221 | Where are remote files trashed to? | 5256 | Where are remote files trashed to? |
| 5222 | 5257 | ||
| 5258 | @vindex remote-file-name-inhibit-delete-by-moving-to-trash | ||
| 5223 | Emacs can trash file instead of deleting | 5259 | Emacs can trash file instead of deleting |
| 5224 | @ifinfo | 5260 | @ifinfo |
| 5225 | them, @ref{Misc File Ops, Trashing , , emacs}. | 5261 | them, @ref{Misc File Ops, Trashing , , emacs}. |
| @@ -50,6 +50,11 @@ as it has in batch mode since Emacs 24. | |||
| 50 | When non-nil, this option suppresses moving remote files to the local | 50 | When non-nil, this option suppresses moving remote files to the local |
| 51 | trash when deleting. Default is nil. | 51 | trash when deleting. Default is nil. |
| 52 | 52 | ||
| 53 | --- | ||
| 54 | ** New user option 'remote-file-name-inhibit-auto-save'. | ||
| 55 | If this user option is non-nil, 'auto-save-mode' will not auto-save | ||
| 56 | remote buffers. The default is nil. | ||
| 57 | |||
| 53 | +++ | 58 | +++ |
| 54 | ** New user option 'yes-or-no-prompt'. | 59 | ** New user option 'yes-or-no-prompt'. |
| 55 | This allows the user to customize the prompt that is appended by | 60 | This 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. | ||
| 9113 | Any 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) |