;; Expand directory wildcards and fill file-list.
(let ((dir-wildcard (and (null file-list) wildcard
(insert-directory-wildcard-in-dir-p dir))))
- (cond (dir-wildcard
+ (cond ((and dir-wildcard (files--use-insert-directory-program-p))
(setq switches (concat "-d " switches))
(let* ((default-directory (car dir-wildcard))
(script (format "%s %s %s"
;; month names; but this should not be necessary any
;; more, with the new value of
;; `directory-listing-before-filename-regexp'.
- (file-list
- (dolist (f file-list)
- (let ((beg (point)))
- (insert-directory f switches nil nil)
- ;; Re-align fields, if necessary.
- (dired-align-file beg (point)))))
+ ((or file-list dir-wildcard)
+ (let ((default-directory
+ (or (car dir-wildcard) default-directory)))
+ (dolist (f (or file-list
+ (file-expand-wildcards (cdr dir-wildcard))))
+ (let ((beg (point)))
+ (insert-directory f switches nil nil)
+ ;; Re-align fields, if necessary.
+ (dired-align-file beg (point))))))
(t
(insert-directory dir switches wildcard (not wildcard))))
;; Quote certain characters, unless ls quoted them for us.
"Directory doesn't exist or is inaccessible"
file))))))
-(declare-function dired-read-dir-and-switches "dired" (str))
-(declare-function dired-goto-next-file "dired" ())
-
-(defun ls-lisp--dired (orig-fun dir-or-list &optional switches)
- (interactive (dired-read-dir-and-switches ""))
- (unless dir-or-list
- (setq dir-or-list default-directory))
- (if (consp dir-or-list)
- (funcall orig-fun dir-or-list switches)
- (let ((dir-wildcard (insert-directory-wildcard-in-dir-p
- (expand-file-name dir-or-list))))
- (if (not dir-wildcard)
- (funcall orig-fun dir-or-list switches)
- (let* ((default-directory (car dir-wildcard))
- (files (file-expand-wildcards (cdr dir-wildcard)))
- (dir (car dir-wildcard)))
- (if files
- (let ((inhibit-read-only t)
- (buf
- (apply orig-fun (nconc (list dir) files) (and switches (list switches)))))
- (with-current-buffer buf
- (save-excursion
- (goto-char (point-min))
- (dired-goto-next-file)
- (forward-line 0)
- (insert " wildcard " (cdr dir-wildcard) "\n"))))
- (user-error "No files matching wildcard")))))))
-
-(advice-add 'dired :around #'ls-lisp--dired)
-
(defun ls-lisp-sanitize (file-alist)
"Sanitize the elements in FILE-ALIST.
Fixes any elements in the alist for directory entries whose file
file-size)
(format " %7s" (file-size-human-readable file-size))))
-(defun ls-lisp-unload-function ()
- "Unload ls-lisp library."
- (advice-remove 'dired #'ls-lisp--dired)
- ;; Continue standard unloading.
- nil)
-
(defun ls-lisp--sanitize-switches (switches)
"Convert long options of GNU \"ls\" to their short form.
Conversion is done only for flags supported by ls-lisp.