fix(dirvish): allow proper buffer switching

This commit is contained in:
Kiana Sheibani 2026-02-04 16:42:10 -05:00
parent d13dd8dc29
commit 8f325d53eb
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -4207,6 +4207,29 @@ If a side session is open, we'll configure =winum= to give it the index ~(popup\
(push #'~/winum-dirvish-side winum-assign-functions))
#+end_src
*** Bug Fixes
**** Buffer Switching
When a full-frame =dirvish= display is switched out of using ~switch-to-buffer~, the fact that Dirvish's buffer is dedicated prevents the switch from working properly. We can fix this by advising that function to clear the =dirvish= session when necessary.
#+begin_src emacs-lisp
(defadvice! ~/switch-to-buffer-dirvish-clear (&rest _)
:before #'switch-to-buffer
(when (featurep 'dirvish)
(when-let ((dv (dirvish-curr)))
(dirvish--clear-session dv))))
;;(defadvice! ~/kill-buffer-dirvish-clear (old-fn buffer-or-name)
;; :around #'kill-buffer
;; (when (featurep 'dirvish)
;; (if-let ((dv (dirvish-curr)))
;; (dirvish--clear-session dv)
;; (if ))))
#+end_src
The optional ~from-quit~ argument on the session clear function is not set, indicating that this switch is not to be treated as a quit-out, and the session will possibly be reused accordingly.
** Emacs Lisp
#+call: confpkg("Mode: Emacs Lisp")