Fix: focus-in-hook and focus-out-hook are obsolete in Emacs27.

Use after-focus-change-function instead of them as suggestion.
This commit is contained in:
Vincent Zhang 2018-10-01 23:12:32 +08:00
parent 8d6aba5b4d
commit 9bb4a71ff8

View file

@ -401,8 +401,11 @@ active.")
;; Show version string for multi-version managers like rvm, rbenv, pyenv, etc.
(defvar-local doom-modeline-env-version nil)
(defvar-local doom-modeline-env-command nil)
(add-hook 'focus-in-hook #'doom-modeline-update-env)
(add-hook 'find-file-hook #'doom-modeline-update-env)
(with-no-warnings
(if (boundp 'after-focus-change-function)
(add-function :after after-focus-change-function #'doom-modeline-update-env)
(add-hook 'focus-in-hook #'doom-modeline-update-env)))
(defun doom-modeline-update-env ()
"Update environment info on mode-line."
(when doom-modeline-env-command
@ -1184,8 +1187,17 @@ See `mode-line-percent-position'.")
"Unfocus mode-line."
(setq doom-modeline-remap-face-cookie (face-remap-add-relative 'mode-line 'mode-line-inactive)))
(with-no-warnings
(if (boundp 'after-focus-change-function)
(progn
(defun doom-modeline-focus-change ()
(if (frame-focus-state)
(doom-modeline-focus)
(doom-modeline-unfocus)))
(add-function :after after-focus-change-function #'doom-modeline-focus-change))
(progn
(add-hook 'focus-in-hook #'doom-modeline-focus)
(add-hook 'focus-out-hook #'doom-modeline-unfocus)
(add-hook 'focus-out-hook #'doom-modeline-unfocus))))
(provide 'doom-modeline)