Fix overeager theme reloading when creating frames

This commit is contained in:
Henrik Lissner 2018-07-25 18:29:04 +02:00
parent c75b2a36ab
commit 44bf6861a6
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -589,19 +589,28 @@ frame's window-system, the theme will be reloaded.")
;; ;;
;; There will still be issues with simultaneous gui and terminal (emacsclient) ;; There will still be issues with simultaneous gui and terminal (emacsclient)
;; frames, however. There's always `doom/reload-theme' if you need it! ;; frames, however. There's always `doom/reload-theme' if you need it!
(defun doom|init-theme-in-frame (frame) (defun doom|reload-theme-in-frame (frame)
"Reloads the theme in new daemon or tty frames." "Reloads the theme in new daemon or tty frames."
(when (and (framep frame) (when (and (framep frame)
(not (eq doom-last-window-system (framep-on-display frame)))) (not (eq doom-last-window-system (framep-on-display frame))))
(with-selected-frame frame (with-selected-frame frame
(doom|init-theme)) (doom|init-theme))
(setq doom-last-window-system (display-graphic-p frame)))) (setq doom-last-window-system (framep-on-display frame))))
(defun doom|reload-theme-maybe (_frame)
"Reloads the theme after closing the last frame of a type."
(unless (cl-loop for fr in (frame-list)
if (eq doom-last-window-system (framep-on-display fr))
return t)
(setq doom-last-window-system nil)
(doom|reload-theme-in-frame (selected-frame))))
;; fonts ;; fonts
(add-hook 'doom-init-ui-hook #'doom|init-fonts) (add-hook 'doom-init-ui-hook #'doom|init-fonts)
;; themes ;; themes
(add-hook 'after-make-frame-functions #'doom|init-theme-in-frame)
(add-hook 'doom-init-ui-hook #'doom|init-theme) (add-hook 'doom-init-ui-hook #'doom|init-theme)
(add-hook 'after-make-frame-functions #'doom|reload-theme-in-frame-maybe)
(add-hook 'after-delete-frame-functions #'doom|reload-theme-maybe)
;; ;;