From 11f4d68f254fd7bb62d5148b78a0c9b1d49b97fe Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 5 Mar 2013 16:55:53 +0100 Subject: [PATCH] * net/tramp-compat.el (tramp-compat-delete-directory): Implement TRASH argument. --- lisp/ChangeLog | 5 +++++ lisp/net/tramp-compat.el | 41 ++++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8feb3df5cdd..ac56cd8ba79 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-03-05 Michael Albinus + + * net/tramp-compat.el (tramp-compat-delete-directory): Implement + TRASH argument. + 2013-03-05 Dmitry Gutov Keep pre-existing highlighting in completion candidates (Bug#13250). diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index 81c4d5ccced..d4639817b18 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -384,25 +384,30 @@ Not actually used. Use `(format \"%o\" i)' instead?" trash))) (delete-file filename))))) -;; RECURSIVE has been introduced with Emacs 23.2. -(defun tramp-compat-delete-directory (directory &optional recursive) +;; RECURSIVE has been introduced with Emacs 23.2. TRASH has been +;; introduced with Emacs 24.1. +(defun tramp-compat-delete-directory (directory &optional recursive trash) "Like `delete-directory' for Tramp files (compat function)." - (if (null recursive) - (delete-directory directory) - (condition-case nil - (tramp-compat-funcall 'delete-directory directory recursive) - ;; This Emacs version does not support the RECURSIVE flag. We - ;; use the implementation from Emacs 23.2. - (wrong-number-of-arguments - (setq directory (directory-file-name (expand-file-name directory))) - (if (not (file-symlink-p directory)) - (mapc (lambda (file) - (if (eq t (car (file-attributes file))) - (tramp-compat-delete-directory file recursive) - (delete-file file))) - (directory-files - directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))) - (delete-directory directory))))) + (condition-case nil + (cond + (trash + (tramp-compat-funcall 'delete-directory directory recursive trash)) + (recursive + (tramp-compat-funcall 'delete-directory directory recursive)) + (t + (delete-directory directory))) + ;; This Emacs version does not support the RECURSIVE or TRASH flag. We + ;; use the implementation from Emacs 23.2. + (wrong-number-of-arguments + (setq directory (directory-file-name (expand-file-name directory))) + (if (not (file-symlink-p directory)) + (mapc (lambda (file) + (if (eq t (car (file-attributes file))) + (tramp-compat-delete-directory file recursive trash) + (tramp-compat-delete-file file trash))) + (directory-files + directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))) + (delete-directory directory)))) ;; `number-sequence' does not exist in XEmacs. Implementation is ;; taken from Emacs 23. -- 2.39.2