Function: dirvish--create-parent-buffer
dirvish--create-parent-buffer is a natively compiled function defined
in dirvish.el.
Signature
(dirvish--create-parent-buffer DV DIR INDEX LEVEL)
Documentation
Create parent buffer at DIR in DV selecting file INDEX.
LEVEL is the depth of current window.
Source Code
;; Defined in /nix/store/1gijwny2yx4fggrsb9l110h1ybs1gdk5-emacs-packages-deps/share/emacs/site-lisp/elpa/dirvish-20260725.1520/dirvish.el
(defun dirvish--create-parent-buffer (dv dir index level)
"Create parent buffer at DIR in DV selecting file INDEX.
LEVEL is the depth of current window."
(let* ((index (directory-file-name index))
(buf (dirvish--special-buffer (format "parent-%s" level) dv t))
(str (or (gethash dir (dv-parent-hash dv))
(let ((flags dired-actual-switches))
(with-temp-buffer (dired-insert-directory dir flags)
(buffer-string)))))
(attrs (mapcar #'car (dv-attributes dv)))
(icon (cond ((memq 'all-the-icons attrs) '(all-the-icons))
((memq 'nerd-icons attrs) '(nerd-icons))
((memq 'vscode-icon attrs) '(vscode-icon)))))
(cl-pushnew buf (dv-special-buffers dv))
(with-current-buffer buf
(dirvish-directory-view-mode)
(dirvish-prop :dv (dv-id dv))
(dirvish-prop :remote (file-remote-p dir))
(dirvish-prop :sudo ; copy this from root avoids requiring tramp
(with-current-buffer (cdr (dv-index dv)) (dirvish-prop :sudo)))
(puthash dir str (dv-parent-hash dv))
(let (buffer-read-only) (erase-buffer) (save-excursion (insert str)))
(setq-local dired-subdir-alist (list (cons dir (point-min-marker))))
(dired-goto-file-1 (file-name-nondirectory index) index (point-max))
(dirvish--maybe-toggle-cursor '(box . 0)) ; always hide cursor in parents
(dirvish-prop :attrs (dirvish--attrs-expand icon)) buf)))