minmo : minmo--window-hook

This commit is contained in:
bth 2026-06-08 21:46:35 -07:00
commit 8562c0c1f3

View file

@ -192,12 +192,15 @@ Optional FORCE means ignore the minmo--git-directory-table."
(add-hook 'after-save-hook #'minmo--update-git-cache) (add-hook 'after-save-hook #'minmo--update-git-cache)
;; NOTE: but normal cache update when window state changes: ;; NOTE: but normal cache update when window state changes:
(defun minmo--update-git-cache-window (frame-or-window) (defun minmo--window-hook (frame-or-window func)
(let ((win (if (framep frame-or-window) (let ((win (if (framep frame-or-window)
(frame-selected-window frame-or-window) (frame-selected-window frame-or-window)
frame-or-window))) frame-or-window)))
(with-current-buffer (window-buffer win) (with-current-buffer (window-buffer win)
(minmo--update-git-cache)))) (funcall func))))
(defun minmo--update-git-cache-window (frame-or-window)
(minmo--window-hook frame-or-window 'minmo--update-git-cache))
;; NOTE: window-state-change-functions includes size changes, which would be spammy. ;; NOTE: window-state-change-functions includes size changes, which would be spammy.
;; this does selection changes, eg other-window: ;; this does selection changes, eg other-window:
@ -261,11 +264,7 @@ Optional FORCE means ignore the minmo--git-directory-table."
(file-exists-p buffer-file-name))))) (file-exists-p buffer-file-name)))))
(defun minmo--update-file-exists-cache-window (frame-or-window) (defun minmo--update-file-exists-cache-window (frame-or-window)
(let ((win (if (framep frame-or-window) (minmo--window-hook frame-or-window 'minmo--update-file-exists-cache))
(frame-selected-window frame-or-window)
frame-or-window)))
(with-current-buffer (window-buffer win)
(minmo--update-file-exists-cache))))
(add-hook 'find-file-hook #'minmo--update-file-exists-cache) (add-hook 'find-file-hook #'minmo--update-file-exists-cache)
;; NOTE: before hook, because revert will refuse when it's gone: ;; NOTE: before hook, because revert will refuse when it's gone: