Function: ls-lisp--dired

ls-lisp--dired is an interactive and byte-compiled function defined in ls-lisp.el.gz.

Signature

(ls-lisp--dired ORIG-FUN DIR-OR-LIST &optional SWITCHES)

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/ls-lisp.el.gz
(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))
               (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
                     (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")))))))