Function: dirvish-dired-noselect-a

dirvish-dired-noselect-a is a natively compiled function defined in dirvish.el.

Signature

(dirvish-dired-noselect-a FN DIR-OR-LIST &optional FLAGS RE)

Documentation

Return buffer for DIR-OR-LIST with FLAGS, FN is dired-noselect.

Source Code

;; Defined in /nix/store/1gijwny2yx4fggrsb9l110h1ybs1gdk5-emacs-packages-deps/share/emacs/site-lisp/elpa/dirvish-20260725.1520/dirvish.el
(defun dirvish-dired-noselect-a (fn dir-or-list &optional flags re)
  "Return buffer for DIR-OR-LIST with FLAGS, FN is `dired-noselect'."
  (let* ((dir (if (consp dir-or-list) (car dir-or-list) dir-or-list))
         (key (file-name-as-directory (expand-file-name dir)))
         (dvc (dirvish-curr))
         (dv (if (and dvc (not (eq (dv-type dvc) 'peek))) dvc
               (or (dirvish--get-session) (dirvish--new))))
         (bname buffer-file-name) (remote (file-remote-p dir))
         (flags (or flags (dv-ls-switches dv)))
         (mc dirvish-large-directory-threshold)
         (buffer (alist-get key (dv-roots dv) nil nil #'equal))
         (new? (null buffer)) (dps (dv-preview-dispatchers dv))
         (hist (cons key nil)) tramp fd)
    (setf (dv-timestamp dv) (dirvish--timestamp))
    (cond ((and new? remote)
           (setq tramp (prog1 'dirvish-tramp-noselect (require 'dirvish-tramp))
                 buffer (apply tramp (list fn dir-or-list flags remote dps))))
          ((or re (and mc (length> (directory-files key nil nil t mc) (1- mc))))
           (setq fd (prog1 'dirvish-fd-noselect (require 'dirvish-fd nil t))
                 buffer (apply fd (list dv key (or re "")))
                 re (if (stringp re) re (mapconcat #'concat re ","))
                 key (concat key "🔍" re)))
          (new? (let (dired-buffers) ; disable reuse from `dired'
                  (setq buffer (apply fn (list dir-or-list flags))))))
    (when (setq new? (null (alist-get key (dv-roots dv) nil nil #'equal)))
      (push (cons key buffer) (dv-roots dv)))
    (unless (member (car hist) (mapcar #'car dired-buffers))
      (setq dired-buffers (seq-take (push hist dired-buffers) 20000)))
    (setcdr (assoc (car hist) dired-buffers) buffer)
    (with-current-buffer buffer
      (dirvish--setup-dired)
      (funcall (dv-root-conf dv) buffer)
      (dirvish-prop :dv (dv-id dv))
      (dirvish-prop :gui (display-graphic-p))
      (dirvish-prop :remote remote)
      (dirvish-prop :root key)
      (unless remote (dirvish-prop :preview-dps dps))
      (dirvish-prop :attrs (dv-attributes dv))
      (cl-loop for (k v) on dirvish--scopes by 'cddr
               do (dirvish-prop k (and (functionp v) (funcall v))))
      (when new? (dirvish--dir-data-async (car hist) buffer))
      (when bname (dired-goto-file bname))
      (setf (dv-index dv) (cons key buffer))
      (run-hook-with-args 'dirvish-find-entry-hook (car hist) 'dired)
      buffer)))