From e190648b811112c3858509f5c3632e32a33e156e Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 25 Jun 2026 11:56:35 -0400 Subject: 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. --- modules/dirvish-config.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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))) -- cgit v1.2.3