refactor: doom-switch-frame-hook

Redesign this hook around `after-focus-change-function`, along with
debouncing, to prevent it from triggering too aggressively (due to
misbehaving desktop environments, elisp packages that tinker with frame
focus, or accidental (and rapid) focus changes by the user).

`doom-switch-{window,buffer}-hook` have also been simplified, and
`doom-switch-window-hook` now will not trigger when focusing another
frame (only when you switch windows *within* any one frame).

This also fixes diff-hl not updating when refocusing an Emacs frame.
This commit is contained in:
Henrik Lissner
2025-04-02 03:14:55 -04:00
parent 27e5ae62e4
commit 653b465c74
5 changed files with 57 additions and 18 deletions

View File

@ -50,7 +50,7 @@ Only has an effect in GUI Emacs.")
;; ...then refresh the rest only when we switch to them or refocus the active
;; frame, not all at once.
(add-hook 'doom-switch-buffer-hook #'+magit-revert-buffer-maybe-h)
(add-hook 'focus-in-hook #'+magit-mark-stale-buffers-h)
(add-hook 'doom-switch-frame-hook #'+magit-mark-stale-buffers-h)
;; The default location for git-credential-cache is in
;; ~/.cache/git/credential. However, if ~/.git-credential-cache/ exists, then