refactor: font, theme, & UI init
Use the new server-after-make-frame-hook, introduced in Emacs 27.1, to clean up how we initialize fonts, themes, and the UI in general. This may indirectly fix font issues in daemon sessions.
This commit is contained in:
parent
0f25a813e1
commit
2614df72bd
1 changed files with 15 additions and 19 deletions
|
@ -592,28 +592,24 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
||||||
(put sym 'saved-face nil))
|
(put sym 'saved-face nil))
|
||||||
(cond
|
(cond
|
||||||
(doom-font
|
(doom-font
|
||||||
|
(when (or reload (daemonp))
|
||||||
|
(set-frame-font doom-font t t t))
|
||||||
;; I avoid `set-frame-font' at startup because it is expensive; doing extra,
|
;; I avoid `set-frame-font' at startup because it is expensive; doing extra,
|
||||||
;; unnecessary work we can avoid by setting the frame parameter directly.
|
;; unnecessary work we can avoid by setting the frame parameter directly.
|
||||||
(setf (alist-get 'font default-frame-alist)
|
(setf (alist-get 'font default-frame-alist)
|
||||||
(cond ((stringp doom-font) doom-font)
|
(cond ((stringp doom-font) doom-font)
|
||||||
((fontp doom-font) (font-xlfd-name doom-font))
|
((fontp doom-font) (font-xlfd-name doom-font))
|
||||||
((signal 'wrong-type-argument
|
((signal 'wrong-type-argument
|
||||||
(list '(fontp stringp) doom-font)))))
|
(list '(fontp stringp) doom-font))))))
|
||||||
(when reload
|
|
||||||
(set-frame-font doom-font t t)))
|
|
||||||
((display-graphic-p)
|
((display-graphic-p)
|
||||||
(setq font-use-system-font t)))
|
(setq font-use-system-font t)))
|
||||||
;; Give users a chance to inject their own font logic.
|
;; Give users a chance to inject their own font logic.
|
||||||
(run-hooks 'after-setting-font-hook))
|
(run-hooks 'after-setting-font-hook))
|
||||||
|
|
||||||
(defun doom-init-theme-h (&optional frame)
|
(defun doom-init-theme-h ()
|
||||||
"Load the theme specified by `doom-theme' in FRAME."
|
"Load the theme specified by `doom-theme' in FRAME."
|
||||||
(when (and doom-theme (not (custom-theme-enabled-p doom-theme)))
|
(when (and doom-theme (not (custom-theme-enabled-p doom-theme)))
|
||||||
;; Fix #1397: if `doom-init-theme-h' is used on `after-make-frame-functions'
|
(load-theme doom-theme t)))
|
||||||
;; (for daemon sessions), the new frame must be focused to ensure the theme
|
|
||||||
;; loads correctly.
|
|
||||||
(with-selected-frame (or frame (selected-frame))
|
|
||||||
(load-theme doom-theme t))))
|
|
||||||
|
|
||||||
(defadvice! doom--load-theme-a (fn theme &optional no-confirm no-enable)
|
(defadvice! doom--load-theme-a (fn theme &optional no-confirm no-enable)
|
||||||
"Record `doom-theme', disable old themes, and trigger `doom-load-theme-hook'."
|
"Record `doom-theme', disable old themes, and trigger `doom-load-theme-hook'."
|
||||||
|
@ -663,16 +659,16 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
||||||
(advice-add fn :around #'doom-run-switch-buffer-hooks-a)))
|
(advice-add fn :around #'doom-run-switch-buffer-hooks-a)))
|
||||||
|
|
||||||
;; Apply `doom-font' et co
|
;; Apply `doom-font' et co
|
||||||
(add-hook 'doom-after-init-modules-hook #'doom-init-fonts-h -100)
|
(let ((hook (if (daemonp) 'server-after-make-frame-hook)))
|
||||||
|
(add-hook (or hook 'after-init-hook)
|
||||||
;; Apply `doom-theme'
|
#'doom-init-fonts-h
|
||||||
(add-hook (if (daemonp)
|
-100)
|
||||||
'after-make-frame-functions
|
(add-hook (or hook 'after-init-hook)
|
||||||
'doom-after-init-modules-hook)
|
#'doom-init-theme-h
|
||||||
#'doom-init-theme-h
|
-90)
|
||||||
-90)
|
(add-hook (or hook 'window-setup-hook)
|
||||||
|
#'doom-init-ui-h
|
||||||
(add-hook 'window-setup-hook #'doom-init-ui-h 100)
|
100))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue