Rewrite how themes are loaded, and fonts reloaded

A follow-up to 578dddd, which wasn't sufficient.

Fixes #5000 (again)
This commit is contained in:
Henrik Lissner 2021-05-07 16:33:07 -04:00
parent 113dcd74cf
commit f989bf60f0
6 changed files with 51 additions and 92 deletions

View file

@ -71,9 +71,7 @@ FRAME parameter defaults to current frame."
"Reload your fonts, if they're set.
See `doom-init-fonts-h'."
(interactive)
(when doom-font
(set-frame-font doom-font t))
(doom-init-fonts-h))
(doom-init-fonts-h 'reload))
;;;###autoload
(defun doom/increase-font-size (count)

View file

@ -28,14 +28,15 @@ all themes. It will apply to all themes once they are loaded."
`(progn
(defun ,fn ()
(let (custom--inhibit-theme-enable)
(dolist (theme (doom-enlist (or ,theme 'user)))
(dolist (theme (doom-enlist (or ,theme 'doom)))
(when (or (eq theme 'user)
(custom-theme-enabled-p theme))
(apply #'custom-theme-set-faces theme
(mapcan #'doom--custom-theme-set-face
(list ,@specs)))))))
(when (or doom-init-theme-p (null doom-theme))
(funcall #',fn))
(unless doom-theme (funcall #',fn))
;; TODO Append to `doom-load-theme-hook' with DEPTH instead when Emacs
;; 26.x support is dropped.
(add-hook 'doom-customize-theme-hook #',fn 'append))))
;;;###autoload
@ -46,17 +47,15 @@ This is a convenience macro alternative to `custom-set-face' which allows for a
simplified face format, and takes care of load order issues, so you can use
doom-themes' API without worry."
(declare (indent defun))
`(custom-theme-set-faces! 'user ,@specs))
`(custom-theme-set-faces! 'doom ,@specs))
;;;###autoload
(defun doom/reload-theme ()
"Reload the current color theme."
(interactive)
(let ((themes (copy-sequence custom-enabled-themes)))
(mapc #'disable-theme custom-enabled-themes)
(dolist (theme themes)
(if (get theme 'theme-feature)
(load-theme theme t)
(enable-theme theme)))
(message "Reloaded themes: %s" (mapconcat #'prin1-to-string themes ", "))
(doom/reload-font)))
(load-theme doom-theme t)
(doom/reload-font)
(message "%s %s"
(propertize "Reloaded themes:" 'face 'bold)
(mapconcat #'prin1-to-string themes ", "))))