refactor: switch buffer/frame/window hooks
Emacs 27 introduced a bunch of `window-*-change-functions` hooks, including `window-selection-change-functions` and `window-buffer-change-functions`, which handles 98% of the use case for Doom's `doom-switch-{buffer,window,frame}-hook` hooks, so I've rewritten them to use them under the hood, which amounts to simpler code and fewer hacks.
This commit is contained in:
parent
2614df72bd
commit
0bb4d4dfcb
4 changed files with 35 additions and 75 deletions
|
@ -147,12 +147,12 @@ more information on modifiers."
|
|||
;; HACK This ping-ponging between the destination and source windows is to
|
||||
;; update the window focus history, so that, if you close either split
|
||||
;; afterwards you won't be sent to some random window.
|
||||
(let ((doom-inhibit-switch-window-hooks t)
|
||||
(origwin (selected-window)))
|
||||
(let ((origwin (selected-window))
|
||||
window-selection-change-functions)
|
||||
(select-window (split-window origwin count 'below))
|
||||
(unless evil-split-window-below
|
||||
(select-window origwin))
|
||||
(run-hooks 'doom-switch-window-hook))
|
||||
(select-window origwin)))
|
||||
(run-hooks 'window-selection-change-functions)
|
||||
(recenter)
|
||||
(when (and (not count) evil-auto-balance-windows)
|
||||
(balance-windows (window-parent)))
|
||||
|
@ -166,13 +166,12 @@ more information on modifiers."
|
|||
;; HACK This ping-ponging between the destination and source windows is to
|
||||
;; update the window focus history, so that, if you close either split
|
||||
;; afterwards you won't be sent to some random window.
|
||||
(let ((doom-inhibit-switch-window-hooks t)
|
||||
(origwin (selected-window)))
|
||||
(let ((origwin (selected-window))
|
||||
window-selection-change-functions)
|
||||
(select-window (split-window origwin count 'right))
|
||||
(unless evil-vsplit-window-right
|
||||
(select-window origwin))
|
||||
(run-hooks 'doom-switch-window-hook))
|
||||
(run-hooks)
|
||||
(select-window origwin)))
|
||||
(run-hooks 'window-selection-change-functions)
|
||||
(recenter)
|
||||
(when (and (not count) evil-auto-balance-windows)
|
||||
(balance-windows (window-parent)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue