Function: find-lisp-find-dired-internal

find-lisp-find-dired-internal is a byte-compiled function defined in find-lisp.el.gz.

Signature

(find-lisp-find-dired-internal DIR FILE-PREDICATE DIRECTORY-PREDICATE BUFFER-NAME &optional OTHER-WINDOW)

Documentation

Run find (Lisp version) and go into Dired mode on a buffer of the output.

Source Code

;; Defined in /usr/src/emacs/lisp/find-lisp.el.gz
;; Most of this is lifted from find-dired.el
;;
(defun find-lisp-find-dired-internal (dir file-predicate
                                          directory-predicate buffer-name
                                          &optional other-window)
  "Run find (Lisp version) and go into Dired mode on a buffer of the output."
  (let ((dired-buffers  dired-buffers)
        (regexp         find-lisp-regexp))
    ;; Expand DIR ("" means `default-directory'), ensuring a trailing slash.
    (setq dir (file-name-as-directory (expand-file-name dir)))
    ;; Check that it's really a directory.
    (or (file-directory-p dir)
	(error "find-dired needs a directory: %s" dir))
    (unless (and (buffer-name)  (string= buffer-name (buffer-name)))
      (let ((buf  (get-buffer-create buffer-name)))
        (if other-window (pop-to-buffer buf) (switch-to-buffer buf))))
    (widen)
    (kill-all-local-variables)
    (setq buffer-read-only nil)
    (erase-buffer)
    (setq default-directory dir)
    (dired-mode dir)

    (use-local-map (append (make-sparse-keymap) (current-local-map)))

    (setq-local find-lisp-file-predicate file-predicate)
    (setq-local find-lisp-directory-predicate directory-predicate)
    (setq-local find-lisp-regexp regexp)

    (setq-local revert-buffer-function
                (lambda (_ignore1 _ignore2)
                  (find-lisp-insert-directory
                   default-directory
                   find-lisp-file-predicate
                   find-lisp-directory-predicate
                   'ignore)))

    ;; Set subdir-alist so that Tree Dired will work:
    (if (fboundp 'dired-simple-subdir-alist)
	;; will work even with nested dired format (dired-nstd.el,v 1.15
	;; and later)
	(dired-simple-subdir-alist)
      ;; else we have an ancient tree dired (or classic dired, where
      ;; this does no harm)
      (setq dired-subdir-alist
            (list (cons default-directory (point-min-marker)))))
    (find-lisp-insert-directory
     dir file-predicate directory-predicate 'ignore)
    (goto-char (point-min))
    (dired-goto-next-file)))