aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2024-04-23 13:54:09 +0200
committerMichael Albinus2024-04-23 13:54:09 +0200
commit956821672eb5306d4eeeae0dc07df4664cef230a (patch)
tree067e3d5e09730345dc20a40cac7b2b1668942533
parent0e139ca741a5a98abc199c9bce277d5d1f262bf3 (diff)
downloademacs-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.texi36
-rw-r--r--lisp/files.el5
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
5444Where are remote files trashed to? 5444Where 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
5447Emacs can trash file instead of deleting 5447Emacs can trash files instead of deleting
5448@ifinfo 5448@ifinfo
5449them, @ref{Misc File Ops, Trashing , , emacs}. 5449them, @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
5456non-@code{nil}, or it is a remote encrypted file (@pxref{Keeping files 5456non-@code{nil}, or it is a remote encrypted file (@pxref{Keeping files
5457encrypted}), which are deleted anyway. 5457encrypted}), which are deleted anyway.
5458 5458
5459@c Since Emacs 30.
5460@vindex trash-directory
5461If you want to trash a remote file into a remote trash directory, you
5462could configure the user option @code{trash-directory} to a
5463connection-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
5459If Emacs is configured to use the XDG conventions for the trash 5482If Emacs is configured to use the XDG conventions for the trash
5460directory, remote files cannot be restored with the respective tools, 5483directory, remote files cannot be restored with the respective tools,
5461because those conventions don't specify remote paths. Such files must 5484because 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
5925How to ignore errors when changing file attributes?
5926
5927@vindex tramp-inhibit-errors-if-setting-file-attributes-fail
5928Sometimes, for example while saving remote files, errors appear when
5929changing file attributes like permissions, time stamps, or ownership.
5930If these errors can be ignored, set user option
5931@code{tramp-inhibit-errors-if-setting-file-attributes-fail} to a
5932non-@code{nil} value. This transforms the error into a warning.
5933
5934
5935@item
5902How to disable other packages from calling @value{tramp}? 5936How to disable other packages from calling @value{tramp}?
5903 5937
5904There are packages that call @value{tramp} without the user ever 5938There 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))))