diff options
| author | Michael Albinus | 2017-05-03 21:49:32 +0200 |
|---|---|---|
| committer | Michael Albinus | 2017-05-03 21:49:32 +0200 |
| commit | a26e33a1a776affcbf8cdd012297d48999ba8e80 (patch) | |
| tree | 6919deda444f6255730730c7631fdb472cf014c8 | |
| parent | b867eb8ecf67e9fb8167d950316ba762ac561b1c (diff) | |
| download | emacs-a26e33a1a776affcbf8cdd012297d48999ba8e80.tar.gz emacs-a26e33a1a776affcbf8cdd012297d48999ba8e80.zip | |
Fix Bug#26763
* lisp/files.el (delete-directory): Call file name handler
with `trash' argument.
* lisp/net/ange-ftp.el (ange-ftp-delete-directory):
* lisp/net/tramp-sh.el (tramp-sh-handle-delete-directory):
Add TRASH arg. Implement it. (Bug#26763)
(tramp-get-remote-trash): Check for `delete-by-moving-to-trash'.
* lisp/net/tramp-adb.el (tramp-adb-handle-delete-directory):
* lisp/net/tramp-smb.el (tramp-smb-handle-delete-directory):
Add _TRASH arg.
| -rw-r--r-- | lisp/files.el | 2 | ||||
| -rw-r--r-- | lisp/net/ange-ftp.el | 8 | ||||
| -rw-r--r-- | lisp/net/tramp-adb.el | 2 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 15 | ||||
| -rw-r--r-- | lisp/net/tramp-smb.el | 2 |
5 files changed, 16 insertions, 13 deletions
diff --git a/lisp/files.el b/lisp/files.el index 0978fa254f6..d193749bb88 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -5477,7 +5477,7 @@ RECURSIVE if DIRECTORY is nonempty." | |||
| 5477 | (let ((handler (find-file-name-handler directory 'delete-directory))) | 5477 | (let ((handler (find-file-name-handler directory 'delete-directory))) |
| 5478 | (cond | 5478 | (cond |
| 5479 | (handler | 5479 | (handler |
| 5480 | (funcall handler 'delete-directory directory recursive)) | 5480 | (funcall handler 'delete-directory directory recursive trash)) |
| 5481 | ((and delete-by-moving-to-trash trash) | 5481 | ((and delete-by-moving-to-trash trash) |
| 5482 | ;; Only move non-empty dir to trash if recursive deletion was | 5482 | ;; Only move non-empty dir to trash if recursive deletion was |
| 5483 | ;; requested. This mimics the non-`delete-by-moving-to-trash' | 5483 | ;; requested. This mimics the non-`delete-by-moving-to-trash' |
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el index cd0ae8d4203..7b8b3fc8809 100644 --- a/lisp/net/ange-ftp.el +++ b/lisp/net/ange-ftp.el | |||
| @@ -4128,15 +4128,15 @@ directory, so that Emacs will know its current contents." | |||
| 4128 | (ange-ftp-add-file-entry dir t)) | 4128 | (ange-ftp-add-file-entry dir t)) |
| 4129 | (ange-ftp-real-make-directory dir))))) | 4129 | (ange-ftp-real-make-directory dir))))) |
| 4130 | 4130 | ||
| 4131 | (defun ange-ftp-delete-directory (dir &optional recursive) | 4131 | (defun ange-ftp-delete-directory (dir &optional recursive trash) |
| 4132 | (if (file-directory-p dir) | 4132 | (if (file-directory-p dir) |
| 4133 | (let ((parsed (ange-ftp-ftp-name dir))) | 4133 | (let ((parsed (ange-ftp-ftp-name dir))) |
| 4134 | (if recursive | 4134 | (if recursive |
| 4135 | (mapc | 4135 | (mapc |
| 4136 | (lambda (file) | 4136 | (lambda (file) |
| 4137 | (if (file-directory-p file) | 4137 | (if (file-directory-p file) |
| 4138 | (ange-ftp-delete-directory file recursive) | 4138 | (ange-ftp-delete-directory file recursive trash) |
| 4139 | (delete-file file))) | 4139 | (delete-file file trash))) |
| 4140 | ;; We do not want to delete "." and "..". | 4140 | ;; We do not want to delete "." and "..". |
| 4141 | (directory-files | 4141 | (directory-files |
| 4142 | dir 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))) | 4142 | dir 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))) |
| @@ -4170,7 +4170,7 @@ directory, so that Emacs will know its current contents." | |||
| 4170 | dir | 4170 | dir |
| 4171 | (cdr result)))) | 4171 | (cdr result)))) |
| 4172 | (ange-ftp-delete-file-entry dir t)) | 4172 | (ange-ftp-delete-file-entry dir t)) |
| 4173 | (ange-ftp-real-delete-directory dir recursive))) | 4173 | (ange-ftp-real-delete-directory dir recursive trash))) |
| 4174 | (error "Not a directory: %s" dir))) | 4174 | (error "Not a directory: %s" dir))) |
| 4175 | 4175 | ||
| 4176 | ;; Make a local copy of FILE and return its name. | 4176 | ;; Make a local copy of FILE and return its name. |
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 240e017279c..a80bc0bdb2a 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -521,7 +521,7 @@ Emacs dired can't find files." | |||
| 521 | (tramp-flush-file-property v (file-name-directory localname)) | 521 | (tramp-flush-file-property v (file-name-directory localname)) |
| 522 | (tramp-flush-directory-property v localname))) | 522 | (tramp-flush-directory-property v localname))) |
| 523 | 523 | ||
| 524 | (defun tramp-adb-handle-delete-directory (directory &optional recursive) | 524 | (defun tramp-adb-handle-delete-directory (directory &optional recursive _trash) |
| 525 | "Like `delete-directory' for Tramp files." | 525 | "Like `delete-directory' for Tramp files." |
| 526 | (setq directory (expand-file-name directory)) | 526 | (setq directory (expand-file-name directory)) |
| 527 | (with-parsed-tramp-file-name (file-truename directory) nil | 527 | (with-parsed-tramp-file-name (file-truename directory) nil |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 475f2b9a5d1..71afb9aeb75 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -2566,7 +2566,7 @@ The method used must be an out-of-band method." | |||
| 2566 | (tramp-shell-quote-argument localname)) | 2566 | (tramp-shell-quote-argument localname)) |
| 2567 | "Couldn't make directory %s" dir)))) | 2567 | "Couldn't make directory %s" dir)))) |
| 2568 | 2568 | ||
| 2569 | (defun tramp-sh-handle-delete-directory (directory &optional recursive) | 2569 | (defun tramp-sh-handle-delete-directory (directory &optional recursive trash) |
| 2570 | "Like `delete-directory' for Tramp files." | 2570 | "Like `delete-directory' for Tramp files." |
| 2571 | (setq directory (expand-file-name directory)) | 2571 | (setq directory (expand-file-name directory)) |
| 2572 | (with-parsed-tramp-file-name directory nil | 2572 | (with-parsed-tramp-file-name directory nil |
| @@ -2574,7 +2574,8 @@ The method used must be an out-of-band method." | |||
| 2574 | (tramp-flush-directory-property v localname) | 2574 | (tramp-flush-directory-property v localname) |
| 2575 | (tramp-barf-unless-okay | 2575 | (tramp-barf-unless-okay |
| 2576 | v (format "cd / && %s %s" | 2576 | v (format "cd / && %s %s" |
| 2577 | (if recursive "rm -rf" "rmdir") | 2577 | (or (and trash (tramp-get-remote-trash v)) |
| 2578 | (if recursive "rm -rf" "rmdir")) | ||
| 2578 | (tramp-shell-quote-argument localname)) | 2579 | (tramp-shell-quote-argument localname)) |
| 2579 | "Couldn't delete %s" directory))) | 2580 | "Couldn't delete %s" directory))) |
| 2580 | 2581 | ||
| @@ -5394,10 +5395,12 @@ Nonexistent directories are removed from spec." | |||
| 5394 | result)))) | 5395 | result)))) |
| 5395 | 5396 | ||
| 5396 | (defun tramp-get-remote-trash (vec) | 5397 | (defun tramp-get-remote-trash (vec) |
| 5397 | "Determine remote `trash' command." | 5398 | "Determine remote `trash' command. |
| 5398 | (with-tramp-connection-property vec "trash" | 5399 | This command is returned only if `delete-by-moving-to-trash' is non-nil." |
| 5399 | (tramp-message vec 5 "Finding a suitable `trash' command") | 5400 | (and delete-by-moving-to-trash |
| 5400 | (tramp-find-executable vec "trash" (tramp-get-remote-path vec)))) | 5401 | (with-tramp-connection-property vec "trash" |
| 5402 | (tramp-message vec 5 "Finding a suitable `trash' command") | ||
| 5403 | (tramp-find-executable vec "trash" (tramp-get-remote-path vec))))) | ||
| 5401 | 5404 | ||
| 5402 | (defun tramp-get-remote-touch (vec) | 5405 | (defun tramp-get-remote-touch (vec) |
| 5403 | "Determine remote `touch' command." | 5406 | "Determine remote `touch' command." |
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 4205376d655..014e1e86011 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el | |||
| @@ -617,7 +617,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 617 | (tramp-compat-file-attribute-modification-time | 617 | (tramp-compat-file-attribute-modification-time |
| 618 | (file-attributes filename)))))) | 618 | (file-attributes filename)))))) |
| 619 | 619 | ||
| 620 | (defun tramp-smb-handle-delete-directory (directory &optional recursive) | 620 | (defun tramp-smb-handle-delete-directory (directory &optional recursive _trash) |
| 621 | "Like `delete-directory' for Tramp files." | 621 | "Like `delete-directory' for Tramp files." |
| 622 | (setq directory (directory-file-name (expand-file-name directory))) | 622 | (setq directory (directory-file-name (expand-file-name directory))) |
| 623 | (when (file-exists-p directory) | 623 | (when (file-exists-p directory) |