summaryrefslogtreecommitdiff
path: root/lisp/net/tramp-compat.el
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2020-11-03 18:47:32 +0100
committerMichael Albinus <michael.albinus@gmx.de>2020-11-03 18:47:32 +0100
commit2fffc1dfdff0a37f826a67d90d8a97091207dcb2 (patch)
tree2e914da389f96559132c38a54bca9cb690801c8d /lisp/net/tramp-compat.el
parentf9d6e463d310db0e1931f26609d938531c56f9c3 (diff)
downloademacs-2fffc1dfdff0a37f826a67d90d8a97091207dcb2.tar.gz
emacs-2fffc1dfdff0a37f826a67d90d8a97091207dcb2.tar.bz2
emacs-2fffc1dfdff0a37f826a67d90d8a97091207dcb2.zip
Some Tramp fixes for directory-files-* and delete-*
* lisp/files.el (delete-directory): Simplify check for trash. * lisp/net/ange-ftp.el (ange-ftp-delete-file): Implement TRASH. * lisp/net/tramp-compat.el (tramp-compat-directory-files) (tramp-compat-directory-files-and-attributes) (tramp-compat-directory-empty-p): New defaliases. * lisp/net/tramp.el (tramp-handle-directory-files-and-attributes) (tramp-skeleton-delete-directory): * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-delete-directory): Use them. * lisp/net/tramp-sh.el (tramp-sh-handle-directory-files-and-attributes): Implement COUNT. * test/lisp/net/tramp-tests.el (tramp-test14-delete-directory): Do not run trash test for ange-ftp. (tramp-test16-directory-files) (tramp-test19-directory-files-and-attributes): Check COUNT argument.
Diffstat (limited to 'lisp/net/tramp-compat.el')
-rw-r--r--lisp/net/tramp-compat.el27
1 files changed, 27 insertions, 0 deletions
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index c554a8d0c2d..9a4e16efe20 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -309,6 +309,30 @@ A nil value for either argument stands for the current time."
(lambda (filename &optional timestamp _flag)
(set-file-times filename timestamp))))
+;; `directory-files' and `directory-files-and-attributes' got argument
+;; COUNT in Emacs 28.1.
+(defalias 'tramp-compat-directory-files
+ (if (equal (tramp-compat-funcall 'func-arity #'directory-files) '(1 . 5))
+ #'directory-files
+ (lambda (directory &optional full match nosort _count)
+ (directory-files directory full match nosort))))
+
+(defalias 'tramp-compat-directory-files-and-attributes
+ (if (equal (tramp-compat-funcall 'func-arity #'directory-files-and-attributes)
+ '(1 . 6))
+ #'directory-files-and-attributes
+ (lambda (directory &optional full match nosort id-format _count)
+ (directory-files-and-attributes directory full match nosort id-format))))
+
+;; `directory-empty-p' is new in Emacs 28.1.
+(defalias 'tramp-compat-directory-empty-p
+ (if (fboundp 'directory-empty-p)
+ #'directory-empty-p
+ (lambda (dir)
+ (and (file-directory-p dir)
+ (null (tramp-compat-directory-files
+ dir nil directory-files-no-dot-files-regexp t 1))))))
+
(add-hook 'tramp-unload-hook
(lambda ()
(unload-feature 'tramp-loaddefs 'force)
@@ -322,5 +346,8 @@ A nil value for either argument stands for the current time."
;;
;; * Starting with Emacs 27.1, there's no need to escape open
;; parentheses with a backslash in docstrings anymore.
+;;
+;; * Starting with Emacs 27.1, there's `make-empty-file'. Could be
+;; used instead of `write-region'.
;;; tramp-compat.el ends here