Minor optimization of doom*switch-buffer-hooks

This commit is contained in:
Henrik Lissner 2018-06-04 21:09:24 +02:00
parent 625a8a9056
commit fdb95d9ee6
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -377,15 +377,15 @@ from the default."
(funcall orig-fn window norecord)) (funcall orig-fn window norecord))
(run-hooks 'doom-after-switch-window-hook)))) (run-hooks 'doom-after-switch-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)
(let ((buf (window-normalize-buffer-to-switch-to buffer-or-name)))
(if (or doom-inhibit-switch-buffer-hooks (if (or doom-inhibit-switch-buffer-hooks
(eq buf (current-buffer))) (eq (window-normalize-buffer-to-switch-to buffer-or-name)
(apply orig-fn buf args) (current-buffer)))
(apply orig-fn buffer-or-name args)
(run-hooks 'doom-before-switch-buffer-hook) (run-hooks 'doom-before-switch-buffer-hook)
(prog1 (prog1
(let ((doom-inhibit-switch-buffer-hooks t)) (let ((doom-inhibit-switch-buffer-hooks t))
(apply orig-fn buf args)) (apply orig-fn buffer-or-name args))
(run-hooks 'doom-after-switch-buffer-hook))))) (run-hooks 'doom-after-switch-buffer-hook))))
(defun doom|init-custom-hooks () (defun doom|init-custom-hooks ()
(advice-add #'select-frame :around #'doom*switch-frame-hooks) (advice-add #'select-frame :around #'doom*switch-frame-hooks)