diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2020-11-01 12:42:29 +0100 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2020-11-01 12:42:29 +0100 |
commit | 06585bb939ed61574a4b79455c58cab02f11f0fc (patch) | |
tree | 551e326730405ce7d0d9b3122fa215ac1d0b0765 /lisp/net/tramp.el | |
parent | 881eeeef9452c42a04f531a9ed18e7c254642a6b (diff) | |
download | emacs-06585bb939ed61574a4b79455c58cab02f11f0fc.tar.gz emacs-06585bb939ed61574a4b79455c58cab02f11f0fc.tar.bz2 emacs-06585bb939ed61574a4b79455c58cab02f11f0fc.zip |
Trash remote files to local trash (Bug#44216)
* doc/misc/tramp.texi (Frequently Asked Questions): Add trashing.
* lisp/net/tramp-adb.el (tramp-adb-handle-delete-directory)
(tramp-adb-handle-delete-file):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-delete-directory)
(tramp-gvfs-handle-delete-file):
* lisp/net/tramp-sh.el (tramp-sh-handle-delete-directory)
(tramp-sh-handle-delete-file):
* lisp/net/tramp-smb.el (tramp-smb-handle-delete-directory)
(tramp-smb-handle-delete-file):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-delete-directory)
(tramp-sudoedit-handle-delete-file): Implement local trash. (Bug#44216)
* lisp/net/tramp-crypt.el (tramp-crypt-handle-delete-directory)
(tramp-crypt-handle-delete-file): Do not trash.
* lisp/net/tramp.el (tramp-skeleton-delete-directory): New defmacro.
* test/lisp/net/tramp-tests.el (tramp-test07-file-exists-p)
(tramp-test14-delete-directory): Add trashing.
Diffstat (limited to 'lisp/net/tramp.el')
-rw-r--r-- | lisp/net/tramp.el | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 0c85025d542..f3966479dbf 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3864,7 +3864,7 @@ It does not support `:stderr'." p)))))) (defun tramp-handle-make-symbolic-link - (target linkname &optional ok-if-already-exists) + (target linkname &optional ok-if-already-exists) "Like `make-symbolic-link' for Tramp files. This is the fallback implementation for backends which do not support symbolic links." @@ -3877,8 +3877,7 @@ support symbolic links." (tramp-run-real-handler #'make-symbolic-link (list target linkname ok-if-already-exists)))) -(defun tramp-handle-shell-command - (command &optional output-buffer error-buffer) +(defun tramp-handle-shell-command (command &optional output-buffer error-buffer) "Like `shell-command' for Tramp files." (let* ((asynchronous (string-match-p "[ \t]*&[ \t]*\\'" command)) (command (substring command 0 asynchronous)) @@ -4662,6 +4661,7 @@ If both files are local, the function returns t." (and (tramp-tramp-file-p file1) (tramp-tramp-file-p file2) (string-equal (file-remote-p file1) (file-remote-p file2))))) +;; See also `file-modes-symbolic-to-number'. (defun tramp-mode-string-to-int (mode-string) "Convert a ten-letter \"drwxrwxrwx\"-style MODE-STRING into mode bits." (let* (case-fold-search @@ -4741,6 +4741,7 @@ If both files are local, the function returns t." "A list of file types returned from the `stat' system call. This is used to map a mode number to a permission string.") +;; See also `file-modes-number-to-symbolic'. (defun tramp-file-mode-from-int (mode) "Turn an integer representing a file MODE into an ls(1)-like string." (let ((type (cdr @@ -5333,6 +5334,25 @@ name of a process or buffer, or nil to default to the current buffer." (lambda () (remove-hook 'interrupt-process-functions #'tramp-interrupt-process)))) +(defmacro tramp-skeleton-delete-directory (directory recursive trash &rest body) + "Skeleton for `tramp-*-handle-delete-directory'. +BODY is the backend specific code." + (declare (indent 3) (debug t)) + `(with-parsed-tramp-file-name (expand-file-name ,directory) nil + (if (and delete-by-moving-to-trash ,trash) + ;; Move non-empty dir to trash only if recursive deletion was + ;; requested. + (if (and (not ,recursive) + (directory-files + ,directory nil directory-files-no-dot-files-regexp)) + (tramp-error + v 'file-error "Directory is not empty, not moving to trash") + (move-file-to-trash ,directory)) + ,@body) + (tramp-flush-directory-properties v localname))) + +(put #'tramp-skeleton-delete-directory 'tramp-suppress-trace t) + ;; Checklist for `tramp-unload-hook' ;; - Unload all `tramp-*' packages ;; - Reset `file-name-handler-alist' |