Function: dirvish-winbuf-change-h
dirvish-winbuf-change-h is a natively compiled function defined in
dirvish.el.
Signature
(dirvish-winbuf-change-h WINDOW)
Documentation
Rebuild layout once buffer in WINDOW changed.
Source Code
;; Defined in /nix/store/1gijwny2yx4fggrsb9l110h1ybs1gdk5-emacs-packages-deps/share/emacs/site-lisp/elpa/dirvish-20260725.1520/dirvish.el
(defun dirvish-winbuf-change-h (window)
"Rebuild layout once buffer in WINDOW changed."
(when-let* ((dv (with-selected-window window (dirvish-curr)))
(dir (car (dv-index dv))) (buf (cdr (dv-index dv)))
(old-tab (with-selected-window window (dirvish-prop :tab)))
(old-frame (with-selected-window window (dirvish-prop :frame)))
(sc (cl-loop for (k v) on dirvish--scopes by 'cddr
append (list k (and (functionp v) (funcall v)))))
(layout t) (frame t) (tab t))
(setq layout (dv-curr-layout dv)
frame (plist-get sc :frame) tab (plist-get sc :tab))
(cl-flet ((killall (bufs) (mapc #'dirvish--kill-buffer bufs))
(build-dv (dv frame dir)
(with-selected-frame frame
(with-selected-window (dirvish--create-root-window dv)
(dirvish-save-dedication
(switch-to-buffer (get-buffer-create "*scratch*")))
(dirvish-save-dedication
(switch-to-buffer (dired-noselect dir)))
(dirvish--build-layout dv)))))
(cond ; created new tab / frame in a reused session, clear the old one
((not (equal old-frame frame))
(killall (append (list buf) (mapcar #'cdr (dv-roots dv))))
(build-dv (dirvish--new :curr-layout layout) frame dir))
((not (equal old-tab tab))
(tab-bar-switch-to-recent-tab)
(killall (append (list buf) (mapcar #'cdr (dv-roots dv))))
(tab-bar-switch-to-recent-tab)
(build-dv (dirvish--new :curr-layout layout) frame dir))
(t (with-selected-window window (dirvish--build-layout dv)))))))