Rename doom-before-switch-*-hook hooks

+ doom-before-switch-buffer-hook => doom-exit-buffer-hook
+ doom-before-switch-window-hook => doom-exit-window-hook
+ doom-after-switch-buffer-hook => doom-enter-buffer-hook
+ doom-after-switch-window-hook => doom-enter-window-hook

Shorter, easier-to-type names that better describe their intended
purpose.

The old names are still usable, but deprecated.
This commit is contained in:
Henrik Lissner 2018-07-02 23:29:53 +02:00
parent 1dc43f9770
commit 81ffed520b
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
6 changed files with 29 additions and 25 deletions

View file

@ -140,7 +140,7 @@ fundamental-mode) for performance sake."
;; Auto-close delimiters and blocks as you type ;; Auto-close delimiters and blocks as you type
(def-package! smartparens (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) :commands (sp-pair sp-local-pair sp-with-modes)
:config :config
(require 'smartparens-config) (require 'smartparens-config)
@ -177,7 +177,7 @@ fundamental-mode) for performance sake."
;; Branching undo ;; Branching undo
(def-package! undo-tree (def-package! undo-tree
:after-call (doom-before-switch-buffer-hook after-find-file) :after-call (doom-exit-buffer-hook after-find-file)
:config :config
;; persistent undo history is known to cause undo history corruption, which ;; persistent undo history is known to cause undo history corruption, which
;; can be very destructive! So disable it! ;; can be very destructive! So disable it!

View file

@ -34,11 +34,11 @@ with `doom/reload-theme').")
(defvar doom-before-switch-window-hook nil (defvar doom-before-switch-window-hook nil
"Hook run before `switch-window' or `switch-frame' are called. See "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 (defvar doom-after-switch-window-hook nil
"Hook run after `switch-window' or `switch-frame' are called. See "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 (defvar doom-before-switch-buffer-hook nil
"Hook run after `switch-to-buffer', `pop-to-buffer' or `display-buffer' are "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 "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. 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 (setq-default
ansi-color-for-comint-mode t 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 ;; undo/redo changes to Emacs' window layout
(def-package! winner (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 :preface (defvar winner-dont-bind-my-keys t) ; I'll bind keys myself
:config (winner-mode +1)) :config (winner-mode +1))
;; highlight matching delimiters ;; highlight matching delimiters
(def-package! paren (def-package! paren
:after-call (after-find-file doom-before-switch-buffer-hook) :after-call (after-find-file doom-exit-buffer-hook)
:config :config
(setq show-paren-delay 0.1 (setq show-paren-delay 0.1
show-paren-highlight-openparen t show-paren-highlight-openparen t
@ -375,19 +379,19 @@ from the default."
(window-minibuffer-p window)) (window-minibuffer-p window))
(funcall orig-fn window norecord) (funcall orig-fn window norecord)
(let ((doom-inhibit-switch-window-hooks t)) (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) (prog1 (funcall orig-fn window norecord)
(with-selected-window window (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) (defun doom*switch-buffer-hooks (orig-fn buffer-or-name &rest args)
(if (or doom-inhibit-switch-buffer-hooks (if (or doom-inhibit-switch-buffer-hooks
(eq (get-buffer buffer-or-name) (current-buffer))) (eq (get-buffer buffer-or-name) (current-buffer)))
(apply orig-fn buffer-or-name args) (apply orig-fn buffer-or-name args)
(let ((doom-inhibit-switch-buffer-hooks t)) (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) (prog1 (apply orig-fn buffer-or-name args)
(with-current-buffer buffer-or-name (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) (defun doom|init-custom-hooks (&optional disable)
(dolist (spec '((select-window . doom*switch-window-hooks) (dolist (spec '((select-window . doom*switch-window-hooks)

View file

@ -76,14 +76,14 @@
(describe "switch-buffer" (describe "switch-buffer"
:var (doom-before-switch-buffer-hook :var (doom-exit-buffer-hook
doom-after-switch-buffer-hook) doom-enter-buffer-hook)
(before-each (before-each
(setq doom-before-switch-buffer-hook '(before-hook) (setq doom-exit-buffer-hook '(before-hook)
doom-after-switch-buffer-hook '(after-hook))) doom-enter-buffer-hook '(after-hook)))
(after-each (after-each
(setq doom-before-switch-buffer-hook nil (setq doom-exit-buffer-hook nil
doom-after-switch-buffer-hook nil)) doom-enter-buffer-hook nil))
(it "should trigger when switching buffers" (it "should trigger when switching buffers"
(switch-to-buffer b) (switch-to-buffer b)
@ -101,8 +101,8 @@
(describe "switch-window" (describe "switch-window"
:var (doom-before-switch-window-hook :var (doom-exit-window-hook
doom-after-switch-window-hook doom-enter-window-hook
x y) x y)
(before-each (before-each
(delete-other-windows) (delete-other-windows)
@ -113,8 +113,8 @@
(select-window x) (select-window x)
(spy-calls-reset 'before-hook) (spy-calls-reset 'before-hook)
(spy-calls-reset 'after-hook) (spy-calls-reset 'after-hook)
(setq doom-before-switch-window-hook '(before-hook) (setq doom-exit-window-hook '(before-hook)
doom-after-switch-window-hook '(after-hook))) doom-enter-window-hook '(after-hook)))
(it "should trigger when switching windows" (it "should trigger when switching windows"
(select-window y) (select-window y)

View file

@ -44,14 +44,14 @@ warning)."
(make-directory +wakatime-home t))) (make-directory +wakatime-home t)))
(global-wakatime-mode +1)) (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)) (advice-remove 'after-find-file #'+wakatime|autostart))
;;;###autoload ;;;###autoload
(defun +wakatime|delayed-autostart (&rest _) (defun +wakatime|delayed-autostart (&rest _)
"Lazily initialize `wakatime-mode' until the next time you switch buffers or "Lazily initialize `wakatime-mode' until the next time you switch buffers or
open a file." 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 ;; this is necessary in case the user opens emacs with file arguments
(advice-add 'after-find-file :before #'+wakatime|autostart)) (advice-add 'after-find-file :before #'+wakatime|autostart))

View file

@ -129,7 +129,7 @@ Possible values:
(add-hook 'window-configuration-change-hook #'+doom-dashboard|resize) (add-hook 'window-configuration-change-hook #'+doom-dashboard|resize)
(add-hook 'window-size-change-functions #'+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 '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) (unless (daemonp)
(add-hook 'after-make-frame-functions #'+doom-dashboard|make-frame)) (add-hook 'after-make-frame-functions #'+doom-dashboard|make-frame))
;; `persp-mode' integration: update `default-directory' when switching ;; `persp-mode' integration: update `default-directory' when switching

View file

@ -6,7 +6,7 @@
;; NOTE In :feature lookup `recenter' is hooked to a bunch of jumping ;; NOTE In :feature lookup `recenter' is hooked to a bunch of jumping
;; commands, which will trigger nav-flash. ;; commands, which will trigger nav-flash.
(add-hook! (add-hook!
'(doom-after-switch-window-hook '(doom-enter-window-hook
imenu-after-jump-hook evil-jumps-post-jump-hook imenu-after-jump-hook evil-jumps-post-jump-hook
counsel-grep-post-action-hook dumb-jump-after-jump-hook) counsel-grep-post-action-hook dumb-jump-after-jump-hook)
#'+nav-flash/blink-cursor) #'+nav-flash/blink-cursor)