diff options
Diffstat (limited to 'modules/dirvish-config.el')
| -rw-r--r-- | modules/dirvish-config.el | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/modules/dirvish-config.el b/modules/dirvish-config.el index 04f9ce20e..81d352dbd 100644 --- a/modules/dirvish-config.el +++ b/modules/dirvish-config.el @@ -41,6 +41,24 @@ (declare-function cj/drill-this-file "org-drill-config") +;; Dirvish/Dired functions called from lazy-loaded packages. +(declare-function dirvish-peek-mode "dirvish") +(declare-function dirvish-side-follow-mode "dirvish") +(declare-function dirvish-quit "dirvish") +(declare-function dired-get-marked-files "dired") +(declare-function dired-dwim-target-directory "dired-aux") +(declare-function dired-get-file-for-visit "dired") +(declare-function dired-get-filename "dired") +(declare-function dired-mark "dired") +(declare-function dired-current-directory "dired") +(declare-function dired-file-name-at-point "dired-x") +(declare-function dired-find-file "dired") +(declare-function project-roots "project") + +;; External package variables referenced before their package loads. +(defvar ediff-after-quit-hook-internal) +(defvar dirvish-side-attributes) + ;; mark files in dirvish, attach in mu4e (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode) @@ -349,7 +367,8 @@ Shadows dired's `P' (`dired-do-print') with this type-aware version." (defun cj/dirvish-drill-file () "Open the Org file at point and start an `org-drill' session on it. -Bound to `S' (\"study\") in `dirvish-mode-map'; refuses anything but a `.org' file." +Bound to `S' (\"study\") in `dirvish-mode-map'; refuses anything but +a `.org' file." (interactive) (let ((file (dired-get-filename nil t))) (unless (and file (not (file-directory-p file)) (string-suffix-p ".org" file t)) @@ -381,18 +400,19 @@ regardless of what file or subdirectory the point is on." "Return the (PROGRAM PRE-FILE-ARG...) list for setting wallpaper under ENV. ENV is a display-server symbol: `x11' picks feh with --bg-fill, `wayland' -picks swww with the img subcommand. Any other value returns nil so the -caller can surface an \"unknown display server\" error. +picks the `set-wallpaper' script (on PATH from dotfiles; it wraps the awww +backend and persists the choice to waypaper's config). Any other value +returns nil so the caller can surface an \"unknown display server\" error. Pure helper used by `cj/set-wallpaper'." (pcase env ('x11 '("feh" "--bg-fill")) - ('wayland '("swww" "img")) + ('wayland '("set-wallpaper")) (_ nil))) (defun cj/set-wallpaper () "Set the image at point as the desktop wallpaper. -Uses feh on X11, swww on Wayland." +Uses feh on X11, the `set-wallpaper' script on Wayland." (interactive) (let* ((raw (dired-file-name-at-point)) (file (and raw (expand-file-name raw))) @@ -466,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))) |
