(if (not dir-wildcard)
(funcall orig-fun dir-or-list switches)
(let* ((default-directory (car dir-wildcard))
- (files (file-expand-wildcards (cdr dir-wildcard)))
+ (wildcard (cdr dir-wildcard))
+ (files (file-expand-wildcards 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
(dired-goto-next-file)
(forward-line 0)
(insert " wildcard " (cdr dir-wildcard) "\n"))))
- (user-error "No files matching regexp")))))))
+ (user-error "No files matching wildcard")))))))
(advice-add 'dired :around #'ls-lisp--dired)