aboutsummaryrefslogtreecommitdiff
path: root/modules/dirvish-config.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-25 11:56:35 -0400
committerCraig Jennings <c@cjennings.net>2026-06-25 11:56:35 -0400
commite190648b811112c3858509f5c3632e32a33e156e (patch)
tree552df2d8225a7ea882b7f655f5ce6aab9ea4466d /modules/dirvish-config.el
parent897e026c8608ba67ff3cbc0d2cfe0dbdbffd0b49 (diff)
downloaddotemacs-e190648b811112c3858509f5c3632e32a33e156e.tar.gz
dotemacs-e190648b811112c3858509f5c3632e32a33e156e.zip
fix(dirvish): reap the Super+F popup session on any frame close
The popup's q (cj/dirvish-popup-quit) reaps the session's dired buffers, but closing the Hyprland float directly or letting it lose focus bypasses q and orphans them, which is the "leaves a load of buffers around" symptom. A delete-frame-functions hook scoped to the "dirvish" popup frame runs dirvish-quit on every close path. Regular C-x d sessions, where multiple dired buffers are wanted for mark-and-move, and the global dired-kill-when-opening-new-dired-buffer (deliberately off for that same reason) are both untouched. Verified: a navigated popup session drops back to baseline when the frame closes without q.
Diffstat (limited to 'modules/dirvish-config.el')
-rw-r--r--modules/dirvish-config.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/dirvish-config.el b/modules/dirvish-config.el
index c4c5f1aae..81d352dbd 100644
--- a/modules/dirvish-config.el
+++ b/modules/dirvish-config.el
@@ -486,6 +486,22 @@ leaves an empty frame behind."
(when (frame-live-p popup) (delete-frame popup)))
(dirvish-quit))))
+(defun cj/--dirvish-popup-reap-on-delete (frame)
+ "Quit the Dirvish session when the Super+F popup FRAME is closed any way.
+`q' runs `cj/dirvish-popup-quit', but closing the Hyprland float directly (or
+letting it lose focus) bypasses that and orphans the session's dired buffers --
+the \"leaves a load of buffers around\" symptom. As a `delete-frame-functions'
+hook this fires on every close path; `dirvish-quit' reaps the session's buffers
+(verified: a navigated session drops back to baseline on quit). Scoped to the
+popup frame so ordinary `C-x d' sessions -- where multiple dired buffers are
+wanted for mark-and-move -- are untouched."
+ (when (and (frame-live-p frame)
+ (equal (frame-parameter frame 'name) "dirvish"))
+ (with-selected-frame frame
+ (ignore-errors (dirvish-quit)))))
+
+(add-hook 'delete-frame-functions #'cj/--dirvish-popup-reap-on-delete)
+
(defun cj/--dirvish-popup-selected-p ()
"Return non-nil when the selected frame is the dirvish popup frame."
(let ((popup (cj/--dirvish-popup-frame)))