parent
4ce521e26b
commit
76a1e8a279
1 changed files with 32 additions and 34 deletions
|
@ -433,53 +433,51 @@ character that looks like a space that `whitespace-mode' won't affect.")
|
||||||
;; Theme & font
|
;; Theme & font
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(defun doom|init-theme (&optional frame)
|
(defun doom|init-theme ()
|
||||||
"Set the theme and load the font, in that order."
|
"Set the theme and load the font, in that order."
|
||||||
(with-selected-frame (or frame (selected-frame))
|
(when doom-theme
|
||||||
(when (and (not (daemonp)) (symbolp doom-theme))
|
(load-theme doom-theme t))
|
||||||
(load-theme doom-theme t))
|
(add-hook 'after-make-frame-functions #'doom|init-theme-in-frame)
|
||||||
(add-hook 'after-make-frame-functions #'doom|init-theme-in-daemon)
|
(run-hooks 'doom-init-theme-hook))
|
||||||
(run-hooks 'doom-init-theme-hook)))
|
|
||||||
|
|
||||||
(defun doom|init-fonts (&optional frame)
|
(defun doom|init-fonts (&optional frame)
|
||||||
"Initialize fonts."
|
"Initialize fonts."
|
||||||
(add-hook 'after-make-frame-functions #'doom|init-fonts)
|
(add-hook 'after-make-frame-functions #'doom|init-fonts)
|
||||||
(if (not frame)
|
(when (fontp doom-font)
|
||||||
(when (fontp doom-font)
|
(map-put default-frame-alist 'font (font-xlfd-name doom-font)))
|
||||||
(map-put default-frame-alist 'font (font-xlfd-name doom-font)))
|
(when (display-graphic-p)
|
||||||
(when (display-graphic-p)
|
(or frame (setq frame (selected-frame)))
|
||||||
(or frame (setq frame (selected-frame)))
|
(condition-case-unless-debug ex
|
||||||
(condition-case-unless-debug ex
|
(progn
|
||||||
(progn
|
(when (fontp doom-font)
|
||||||
(when (fontp doom-font)
|
(set-face-attribute 'fixed-pitch frame :font doom-font))
|
||||||
(set-face-attribute 'fixed-pitch frame :font doom-font))
|
;; Fallback to `doom-unicode-font' for Unicode characters
|
||||||
;; Fallback to `doom-unicode-font' for Unicode characters
|
(when (fontp doom-unicode-font)
|
||||||
(when (fontp doom-unicode-font)
|
(set-fontset-font t 'unicode doom-unicode-font frame))
|
||||||
(set-fontset-font t 'unicode doom-unicode-font frame))
|
;; ...and for variable-pitch-mode:
|
||||||
;; ...and for variable-pitch-mode:
|
(when (fontp doom-variable-pitch-font)
|
||||||
(when (fontp doom-variable-pitch-font)
|
(set-face-attribute 'variable-pitch frame :font doom-variable-pitch-font)))
|
||||||
(set-face-attribute 'variable-pitch frame :font doom-variable-pitch-font)))
|
('error
|
||||||
('error
|
(if (string-prefix-p "Font not available: " (error-message-string ex))
|
||||||
(if (string-prefix-p "Font not available: " (error-message-string ex))
|
(lwarn 'doom-ui :warning
|
||||||
(lwarn 'doom-ui :warning
|
"Could not find the '%s' font on your system, falling back to system font"
|
||||||
"Could not find the '%s' font on your system, falling back to system font"
|
(font-get (caddr ex) :family))
|
||||||
(font-get (caddr ex) :family))
|
(lwarn 'doom-ui :error
|
||||||
(lwarn 'doom-ui :error
|
"Unexpected error while initializing fonts: %s"
|
||||||
"Unexpected error while initializing fonts: %s"
|
(error-message-string ex)))))))
|
||||||
(error-message-string ex))))))))
|
|
||||||
|
|
||||||
;; Getting themes to remain consistent across GUI Emacs, terminal Emacs and
|
;; Getting themes to remain consistent across GUI Emacs, terminal Emacs and
|
||||||
;; daemon Emacs is hairy. `doom|init-theme' sorts out the initial GUI frame.
|
;; daemon Emacs is hairy. `doom|init-theme' sorts out the initial GUI frame.
|
||||||
;; Attaching that hook to `after-make-frame-functions' sorts out daemon and
|
;; Attaching `doom|init-theme-in-frame' to `after-make-frame-functions' sorts
|
||||||
;; emacsclient frames.
|
;; out daemon and emacsclient frames.
|
||||||
;;
|
;;
|
||||||
;; 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-daemon (frame)
|
(defun doom|init-theme-in-frame (frame)
|
||||||
"Reloads the theme in new daemon or tty frames."
|
"Reloads the theme in new daemon or tty frames."
|
||||||
(when (or (daemonp) (not (display-graphic-p)))
|
(when (or (daemonp) (not (display-graphic-p)))
|
||||||
(doom|init-theme frame)
|
(with-selected-frame frame
|
||||||
(remove-hook 'after-make-frame-functions #'doom|init-theme-in-daemon)))
|
(doom|init-theme))))
|
||||||
|
|
||||||
(add-hook! 'doom-init-ui-hook #'(doom|init-theme doom|init-fonts))
|
(add-hook! 'doom-init-ui-hook #'(doom|init-theme doom|init-fonts))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue