diff options
| author | Michael Albinus | 2024-04-23 13:54:09 +0200 |
|---|---|---|
| committer | Michael Albinus | 2024-04-23 13:54:09 +0200 |
| commit | 956821672eb5306d4eeeae0dc07df4664cef230a (patch) | |
| tree | 067e3d5e09730345dc20a40cac7b2b1668942533 | |
| parent | 0e139ca741a5a98abc199c9bce277d5d1f262bf3 (diff) | |
| download | emacs-956821672eb5306d4eeeae0dc07df4664cef230a.tar.gz emacs-956821672eb5306d4eeeae0dc07df4664cef230a.zip | |
Support remote trash-directory
* doc/misc/tramp.texi (Frequently Asked Questions): Describe how
to manipulate trash-directory.
Explain tramp-inhibit-errors-if-setting-file-attributes-fail.
* lisp/files.el (move-file-to-trash): Use connection-local value
of `trash-directory'. (Bug#70421)
| -rw-r--r-- | doc/misc/tramp.texi | 36 | ||||
| -rw-r--r-- | lisp/files.el | 5 |
2 files changed, 38 insertions, 3 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index b503ce13373..c87d0e70bb4 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi | |||
| @@ -5444,7 +5444,7 @@ HISTFILE=/dev/null | |||
| 5444 | Where are remote files trashed to? | 5444 | Where are remote files trashed to? |
| 5445 | 5445 | ||
| 5446 | @vindex remote-file-name-inhibit-delete-by-moving-to-trash | 5446 | @vindex remote-file-name-inhibit-delete-by-moving-to-trash |
| 5447 | Emacs can trash file instead of deleting | 5447 | Emacs can trash files instead of deleting |
| 5448 | @ifinfo | 5448 | @ifinfo |
| 5449 | them, @ref{Misc File Ops, Trashing , , emacs}. | 5449 | them, @ref{Misc File Ops, Trashing , , emacs}. |
| 5450 | @end ifinfo | 5450 | @end ifinfo |
| @@ -5456,6 +5456,29 @@ option @code{remote-file-name-inhibit-delete-by-moving-to-trash} is | |||
| 5456 | non-@code{nil}, or it is a remote encrypted file (@pxref{Keeping files | 5456 | non-@code{nil}, or it is a remote encrypted file (@pxref{Keeping files |
| 5457 | encrypted}), which are deleted anyway. | 5457 | encrypted}), which are deleted anyway. |
| 5458 | 5458 | ||
| 5459 | @c Since Emacs 30. | ||
| 5460 | @vindex trash-directory | ||
| 5461 | If you want to trash a remote file into a remote trash directory, you | ||
| 5462 | could configure the user option @code{trash-directory} to a | ||
| 5463 | connection-local value. | ||
| 5464 | @ifinfo | ||
| 5465 | @xref{Connection Variables, , , emacs}. | ||
| 5466 | @end ifinfo | ||
| 5467 | |||
| 5468 | @lisp | ||
| 5469 | @group | ||
| 5470 | (connection-local-set-profile-variables | ||
| 5471 | 'remote-trash-directory | ||
| 5472 | '((trash-directory . "/sudo::~/.local/share/Trash"))) | ||
| 5473 | @end group | ||
| 5474 | |||
| 5475 | @group | ||
| 5476 | (connection-local-set-profiles | ||
| 5477 | `(:application tramp :protocol "sudo" :machine ,system-name) | ||
| 5478 | 'remote-trash-directory) | ||
| 5479 | @end group | ||
| 5480 | @end lisp | ||
| 5481 | |||
| 5459 | If Emacs is configured to use the XDG conventions for the trash | 5482 | If Emacs is configured to use the XDG conventions for the trash |
| 5460 | directory, remote files cannot be restored with the respective tools, | 5483 | directory, remote files cannot be restored with the respective tools, |
| 5461 | because those conventions don't specify remote paths. Such files must | 5484 | because those conventions don't specify remote paths. Such files must |
| @@ -5899,6 +5922,17 @@ non-@code{nil} value. This transforms the error into a warning. | |||
| 5899 | 5922 | ||
| 5900 | 5923 | ||
| 5901 | @item | 5924 | @item |
| 5925 | How to ignore errors when changing file attributes? | ||
| 5926 | |||
| 5927 | @vindex tramp-inhibit-errors-if-setting-file-attributes-fail | ||
| 5928 | Sometimes, for example while saving remote files, errors appear when | ||
| 5929 | changing file attributes like permissions, time stamps, or ownership. | ||
| 5930 | If these errors can be ignored, set user option | ||
| 5931 | @code{tramp-inhibit-errors-if-setting-file-attributes-fail} to a | ||
| 5932 | non-@code{nil} value. This transforms the error into a warning. | ||
| 5933 | |||
| 5934 | |||
| 5935 | @item | ||
| 5902 | How to disable other packages from calling @value{tramp}? | 5936 | How to disable other packages from calling @value{tramp}? |
| 5903 | 5937 | ||
| 5904 | There are packages that call @value{tramp} without the user ever | 5938 | There are packages that call @value{tramp} without the user ever |
diff --git a/lisp/files.el b/lisp/files.el index 9f5ed85ce60..7dec67c5cf0 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -8812,9 +8812,10 @@ Otherwise, trash FILENAME using the freedesktop.org conventions, | |||
| 8812 | ;; If `system-move-file-to-trash' is defined, use it. | 8812 | ;; If `system-move-file-to-trash' is defined, use it. |
| 8813 | (cond ((fboundp 'system-move-file-to-trash) | 8813 | (cond ((fboundp 'system-move-file-to-trash) |
| 8814 | (system-move-file-to-trash filename)) | 8814 | (system-move-file-to-trash filename)) |
| 8815 | (trash-directory | 8815 | ((connection-local-value trash-directory) |
| 8816 | ;; If `trash-directory' is non-nil, move the file there. | 8816 | ;; If `trash-directory' is non-nil, move the file there. |
| 8817 | (let* ((trash-dir (expand-file-name trash-directory)) | 8817 | (let* ((trash-dir (expand-file-name |
| 8818 | (connection-local-value trash-directory))) | ||
| 8818 | (fn (directory-file-name (expand-file-name filename))) | 8819 | (fn (directory-file-name (expand-file-name filename))) |
| 8819 | (new-fn (concat (file-name-as-directory trash-dir) | 8820 | (new-fn (concat (file-name-as-directory trash-dir) |
| 8820 | (file-name-nondirectory fn)))) | 8821 | (file-name-nondirectory fn)))) |