(dolist (dir (nreverse dirs))
(when (or (null dir) ; Possible if DIRPART is not wild.
(file-accessible-directory-p dir))
- (let ((this-dir-contents
- ;; Filter out "." and ".."
- (delq nil
- (mapcar (lambda (name)
- (unless (string-match "\\`\\.\\.?\\'"
- (file-name-nondirectory name))
- name))
- (directory-files
- (or dir ".") full
- (if regexp
- ;; We're matching each file name
- ;; element separately.
- (concat "\\`" nondir "\\'")
- (wildcard-to-regexp nondir)))))))
- (setq contents
- (nconc
- (if (and dir (not full))
- (mapcar (lambda (name) (concat dir name))
- this-dir-contents)
- this-dir-contents)
- contents)))))
+ (if (equal "" nondir)
+ ;; `nondir' is "" when the pattern ends in "/". Basically ""
+ ;; refers to the directory itself, like ".", but it's not
+ ;; among the names returned by `directory-files', so we have
+ ;; to special-case it.
+ (push (or dir nondir) contents)
+ (let ((this-dir-contents
+ ;; Filter out "." and ".."
+ (delq nil
+ (mapcar (lambda (name)
+ (unless (string-match "\\`\\.\\.?\\'"
+ (file-name-nondirectory
+ name))
+ name))
+ (directory-files
+ (or dir ".") full
+ (if regexp
+ ;; We're matching each file name
+ ;; element separately.
+ (concat "\\`" nondir "\\'")
+ (wildcard-to-regexp nondir)))))))
+ (setq contents
+ (nconc
+ (if (and dir (not full))
+ (mapcar (lambda (name) (concat dir name))
+ this-dir-contents)
+ this-dir-contents)
+ contents))))))
contents)))
(defcustom find-sibling-rules nil
(purecopy "ls"))
"Absolute or relative name of the `ls'-like program.
This is used by `insert-directory' and `dired-insert-directory'
-(thus, also by `dired'). For Dired, this should ideally point to
+\(thus, also by `dired'). For Dired, this should ideally point to
GNU ls, or another version of ls that supports the \"--dired\"
flag. See `dired-use-ls-dired'.
(if (not dir-wildcard)
(funcall orig-fun dir-or-list switches)
(let* ((default-directory (car dir-wildcard))
- (wildcard (cdr dir-wildcard))
- (files (file-expand-wildcards wildcard))
+ (files (file-expand-wildcards (cdr dir-wildcard)))
(dir (car dir-wildcard)))
- ;; When the wildcard ends in a slash, file-expand-wildcards
- ;; returns nil; fix that by treating the wildcards as
- ;; specifying only directories whose names match the
- ;; widlcard.
- (if (and (null files)
- (directory-name-p wildcard))
- (setq files
- (delq nil
- (mapcar (lambda (fname)
- (if (file-accessible-directory-p fname)
- fname))
- (file-expand-wildcards
- (directory-file-name wildcard))))))
(if files
(let ((inhibit-read-only t)
(buf