diff --git a/core/core-editor.el b/core/core-editor.el index 3085e878d..33e9a9112 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -140,7 +140,7 @@ fundamental-mode) for performance sake." ;; Auto-close delimiters and blocks as you type (def-package! smartparens - :after-call (doom-before-switch-buffer-hook after-find-file) + :after-call (doom-exit-buffer-hook after-find-file) :commands (sp-pair sp-local-pair sp-with-modes) :config (require 'smartparens-config) @@ -177,7 +177,7 @@ fundamental-mode) for performance sake." ;; Branching undo (def-package! undo-tree - :after-call (doom-before-switch-buffer-hook after-find-file) + :after-call (doom-exit-buffer-hook after-find-file) :config ;; persistent undo history is known to cause undo history corruption, which ;; can be very destructive! So disable it! diff --git a/core/core-ui.el b/core/core-ui.el index 63c280a9d..b6572cf1f 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -34,11 +34,11 @@ with `doom/reload-theme').") (defvar doom-before-switch-window-hook nil "Hook run before `switch-window' or `switch-frame' are called. See -`doom-after-switch-window-hook'.") +`doom-enter-window-hook'.") (defvar doom-after-switch-window-hook nil "Hook run after `switch-window' or `switch-frame' are called. See -`doom-before-switch-window-hook'.") +`doom-exit-window-hook'.") (defvar doom-before-switch-buffer-hook nil "Hook run after `switch-to-buffer', `pop-to-buffer' or `display-buffer' are @@ -50,8 +50,12 @@ Also see `doom-after-switch-buffer-hook'.") "Hook run before `switch-to-buffer', `pop-to-buffer' or `display-buffer' are called. The buffer to be switched to is current when these hooks run. -Also see `doom-before-switch-buffer-hook'.") +Also see `doom-exit-buffer-hook'.") +(define-obsolete-variable-alias 'doom-after-switch-buffer-hook 'doom-enter-buffer-hook "2.1.0") +(define-obsolete-variable-alias 'doom-before-switch-buffer-hook 'doom-exit-buffer-hook "2.1.0") +(define-obsolete-variable-alias 'doom-after-switch-window-hook 'doom-enter-window-hook "2.1.0") +(define-obsolete-variable-alias 'doom-before-switch-window-hook 'doom-exit-window-hook "2.1.0") (setq-default ansi-color-for-comint-mode t @@ -304,13 +308,13 @@ DEFAULT is non-nil, set the default mode-line for all buffers." ;; undo/redo changes to Emacs' window layout (def-package! winner - :after-call doom-before-switch-window-hook + :after-call doom-exit-window-hook :preface (defvar winner-dont-bind-my-keys t) ; I'll bind keys myself :config (winner-mode +1)) ;; highlight matching delimiters (def-package! paren - :after-call (after-find-file doom-before-switch-buffer-hook) + :after-call (after-find-file doom-exit-buffer-hook) :config (setq show-paren-delay 0.1 show-paren-highlight-openparen t @@ -375,19 +379,19 @@ from the default." (window-minibuffer-p window)) (funcall orig-fn window norecord) (let ((doom-inhibit-switch-window-hooks t)) - (run-hooks 'doom-before-switch-window-hook) + (run-hooks 'doom-exit-window-hook) (prog1 (funcall orig-fn window norecord) (with-selected-window window - (run-hooks 'doom-after-switch-window-hook)))))) + (run-hooks 'doom-enter-window-hook)))))) (defun doom*switch-buffer-hooks (orig-fn buffer-or-name &rest args) (if (or doom-inhibit-switch-buffer-hooks (eq (get-buffer buffer-or-name) (current-buffer))) (apply orig-fn buffer-or-name args) (let ((doom-inhibit-switch-buffer-hooks t)) - (run-hooks 'doom-before-switch-buffer-hook) + (run-hooks 'doom-exit-buffer-hook) (prog1 (apply orig-fn buffer-or-name args) (with-current-buffer buffer-or-name - (run-hooks 'doom-after-switch-buffer-hook)))))) + (run-hooks 'doom-enter-buffer-hook)))))) (defun doom|init-custom-hooks (&optional disable) (dolist (spec '((select-window . doom*switch-window-hooks) diff --git a/core/test/test-core-ui.el b/core/test/test-core-ui.el index d347392f9..c9471f0bb 100644 --- a/core/test/test-core-ui.el +++ b/core/test/test-core-ui.el @@ -76,14 +76,14 @@ (describe "switch-buffer" - :var (doom-before-switch-buffer-hook - doom-after-switch-buffer-hook) + :var (doom-exit-buffer-hook + doom-enter-buffer-hook) (before-each - (setq doom-before-switch-buffer-hook '(before-hook) - doom-after-switch-buffer-hook '(after-hook))) + (setq doom-exit-buffer-hook '(before-hook) + doom-enter-buffer-hook '(after-hook))) (after-each - (setq doom-before-switch-buffer-hook nil - doom-after-switch-buffer-hook nil)) + (setq doom-exit-buffer-hook nil + doom-enter-buffer-hook nil)) (it "should trigger when switching buffers" (switch-to-buffer b) @@ -101,8 +101,8 @@ (describe "switch-window" - :var (doom-before-switch-window-hook - doom-after-switch-window-hook + :var (doom-exit-window-hook + doom-enter-window-hook x y) (before-each (delete-other-windows) @@ -113,8 +113,8 @@ (select-window x) (spy-calls-reset 'before-hook) (spy-calls-reset 'after-hook) - (setq doom-before-switch-window-hook '(before-hook) - doom-after-switch-window-hook '(after-hook))) + (setq doom-exit-window-hook '(before-hook) + doom-enter-window-hook '(after-hook))) (it "should trigger when switching windows" (select-window y) diff --git a/modules/tools/wakatime/autoload.el b/modules/tools/wakatime/autoload.el index 37eb972f1..4e9a81da7 100644 --- a/modules/tools/wakatime/autoload.el +++ b/modules/tools/wakatime/autoload.el @@ -44,14 +44,14 @@ warning)." (make-directory +wakatime-home t))) (global-wakatime-mode +1)) ;; - (remove-hook 'doom-before-switch-buffer-hook #'+wakatime|autostart) + (remove-hook 'doom-exit-buffer-hook #'+wakatime|autostart) (advice-remove 'after-find-file #'+wakatime|autostart)) ;;;###autoload (defun +wakatime|delayed-autostart (&rest _) "Lazily initialize `wakatime-mode' until the next time you switch buffers or open a file." - (add-hook 'doom-before-switch-buffer-hook #'+wakatime|autostart) + (add-hook 'doom-exit-buffer-hook #'+wakatime|autostart) ;; this is necessary in case the user opens emacs with file arguments (advice-add 'after-find-file :before #'+wakatime|autostart)) diff --git a/modules/ui/doom-dashboard/config.el b/modules/ui/doom-dashboard/config.el index f613309f8..9020c0dc7 100644 --- a/modules/ui/doom-dashboard/config.el +++ b/modules/ui/doom-dashboard/config.el @@ -129,7 +129,7 @@ Possible values: (add-hook 'window-configuration-change-hook #'+doom-dashboard|resize) (add-hook 'window-size-change-functions #'+doom-dashboard|resize) (add-hook 'kill-buffer-query-functions #'+doom-dashboard|reload-on-kill) - (add-hook 'doom-after-switch-buffer-hook #'+doom-dashboard|reload-on-kill) + (add-hook 'doom-enter-buffer-hook #'+doom-dashboard|reload-on-kill) (unless (daemonp) (add-hook 'after-make-frame-functions #'+doom-dashboard|make-frame)) ;; `persp-mode' integration: update `default-directory' when switching diff --git a/modules/ui/nav-flash/config.el b/modules/ui/nav-flash/config.el index 3ab42ec28..3adf6ed9f 100644 --- a/modules/ui/nav-flash/config.el +++ b/modules/ui/nav-flash/config.el @@ -6,7 +6,7 @@ ;; NOTE In :feature lookup `recenter' is hooked to a bunch of jumping ;; commands, which will trigger nav-flash. (add-hook! - '(doom-after-switch-window-hook + '(doom-enter-window-hook imenu-after-jump-hook evil-jumps-post-jump-hook counsel-grep-post-action-hook dumb-jump-after-jump-hook) #'+nav-flash/blink-cursor)