diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2020-11-02 17:56:06 +0100 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2020-11-02 17:56:06 +0100 |
commit | e654b41c6f9eae424736bc8845d92b9dd97ccd3e (patch) | |
tree | 53c7d09c4e5efd8f281888bc13527844a5933136 /lisp | |
parent | 554495006e8d33a06c5df63fd8767c1124e1ed9e (diff) | |
download | emacs-e654b41c6f9eae424736bc8845d92b9dd97ccd3e.tar.gz emacs-e654b41c6f9eae424736bc8845d92b9dd97ccd3e.tar.bz2 emacs-e654b41c6f9eae424736bc8845d92b9dd97ccd3e.zip |
Fix some glitches in recent directory-files-* changes
* doc/lispref/files.texi (Contents of Directories):
Fix description of directory-files, directory-empty-p and
directory-files-and-attributes.
* etc/NEWS: Fix entry for directory-files-and-attributes. Fix typos.
* lisp/dired.el (directory-empty-p): Move function from here ...
* lisp/files.el (directory-empty-p): ... to here.
* lisp/net/ange-ftp.el (ange-ftp-directory-files): Call `nreverse' later.
* lisp/net/tramp.el (tramp-handle-directory-files):
* lisp/net/tramp-adb.el
(tramp-adb-handle-directory-files-and-attributes): Do not call
`nreverse'.
* src/dired.c (Fdirectory_files)
(Fdirectory_files_and_attributes): Fix docstrings.
* test/src/dired-tests.el: Removed. Tests moved to
test/lisp/dired-tests.el.
* test/lisp/dired-tests.el (dired-test-bug27899): Tag it :unstable.
(dired-test-directory-files)
(dired-test-directory-files-and-attributes): New tests.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/dired.el | 14 | ||||
-rw-r--r-- | lisp/files.el | 10 | ||||
-rw-r--r-- | lisp/net/ange-ftp.el | 6 | ||||
-rw-r--r-- | lisp/net/tramp-adb.el | 14 | ||||
-rw-r--r-- | lisp/net/tramp-sh.el | 5 | ||||
-rw-r--r-- | lisp/net/tramp-smb.el | 2 | ||||
-rw-r--r-- | lisp/net/tramp.el | 4 |
7 files changed, 26 insertions, 29 deletions
diff --git a/lisp/dired.el b/lisp/dired.el index 5ac2f203347..08b19a02250 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -3016,20 +3016,6 @@ dired-buffers." ;; Tree Dired ;;; utility functions -(defun directory-empty-p (filename) - "Return t if FILENAME names an existing directory containing no -other files. Return nil if FILENAME does not name a directory, or if -there was trouble determining whether DIRECTORYNAME is a directory or empty. - -As a special case, this function will also return t if FILENAME is the -empty string (\"\"). This quirk is due to Emacs interpreting the -empty string (in some cases) as the current directory. - -Symbolic links to directories count as directories. -See `file-symlink-p' to distinguish symlinks. " - (and (file-directory-p filename) - (null (directory-files - filename nil directory-files-no-dot-files-regexp t 1)))) (defun dired-in-this-tree-p (file dir) ;;"Is FILE part of the directory tree starting at DIR?" diff --git a/lisp/files.el b/lisp/files.el index 59bcc3e8a78..e55552a2d9a 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -888,6 +888,16 @@ recursion." (push (concat dir "/" file) files))))) (nconc result (nreverse files)))) +(defun directory-empty-p (dir) + "Return t if DIR names an existing directory containing no other files. +Return nil if DIR does not name a directory, or if there was +trouble determining whether DIR is a directory or empty. + +Symbolic links to directories count as directories. +See `file-symlink-p' to distinguish symlinks." + (and (file-directory-p dir) + (null (directory-files dir nil directory-files-no-dot-files-regexp t 1)))) + (defvar module-file-suffix) (defun load-file (file) diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el index 7ce90504ba3..15322219eff 100644 --- a/lisp/net/ange-ftp.el +++ b/lisp/net/ange-ftp.el @@ -3442,9 +3442,9 @@ system TYPE.") (if (or (not match) (string-match-p match f)) (setq files (cons (if full (concat directory f) f) files)))) - (nreverse files)) - (when (natnump count) - (setq files (last files count)))) + (when (natnump count) + (setq files (last files count))) + (nreverse files))) (apply 'ange-ftp-real-directory-files directory full match nosort count))) (defun ange-ftp-directory-files-and-attributes diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index e8dbe1618d0..8ccbe412f2b 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -344,14 +344,14 @@ ARGUMENTS to pass to the OPERATION." (sort result (lambda (x y) (string< (car x) (car y)))))) (setq result (delq nil - (mapcar (lambda (x) (if (or (not match) - (string-match-p - match (car x))) - x)) result))) + (mapcar + (lambda (x) (if (or (not match) + (string-match-p + match (car x))) + x)) + result))) (when (natnump count) - (setq result (last result count)) - (nreverse result)) - + (setq result (last result count))) result))))))) (defun tramp-adb-get-ls-command (vec) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 7afd6fac47d..915ce2f6a65 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -1701,6 +1701,7 @@ ID-FORMAT valid values are `string' and `integer'." (tramp-get-remote-gid v 'integer))))))))) ;; Directory listings. + (defun tramp-sh-handle-directory-files-and-attributes (directory &optional full match nosort id-format count) "Like `directory-files-and-attributes' for Tramp files." @@ -1744,7 +1745,7 @@ ID-FORMAT valid values are `string' and `integer'." (tramp-handle-directory-files-and-attributes directory full match nosort id-format count))))) -;; FIXME Fix function to work with count parameter. +;; FIXME: Fix function to work with count parameter. (defun tramp-do-directory-files-and-attributes-with-perl (vec localname &optional id-format) "Implement `directory-files-and-attributes' for Tramp files using a Perl script." @@ -1760,7 +1761,7 @@ ID-FORMAT valid values are `string' and `integer'." (when (stringp object) (tramp-error vec 'file-error object)) object)) -;; FIXME Fix function to work with count parameter. +;; FIXME: Fix function to work with count parameter. (defun tramp-do-directory-files-and-attributes-with-stat (vec localname &optional id-format) "Implement `directory-files-and-attributes' for Tramp files using stat(1) command." diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index b3b6a94e9cc..3220e516050 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -704,7 +704,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (mapcar (lambda (x) (when (string-match-p match x) x)) result)))) - ;; return count number of results + ;; Return count number of results. (when (and (natnump count) (> count 0)) (setq result (nbutlast result (- (length result) count)))) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 25fa9754881..ce0a2b54ff5 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3135,8 +3135,8 @@ User is always nil." (unless nosort (setq result (sort result #'string<))) (when (natnump count) - (setq result (last file count)) - (nreverse files))))) + (setq result (last result count))) + result))) (defun tramp-handle-directory-files-and-attributes (directory &optional full match nosort id-format count) |