Revert to 'user theme

Trying to get 'doom to behave like 'user is too much trouble and causes
too many problems. The magic around 'user is too deeply woven into
custom.el. The whole custom.el fiasco needs to be dealt with another
way.

Fixes #5000
Fixes #5009
This commit is contained in:
Henrik Lissner 2021-05-09 20:12:45 -04:00
parent a1fdc77dc1
commit cebbd76f3d
2 changed files with 17 additions and 29 deletions

View file

@ -28,8 +28,8 @@ all themes. It will apply to all themes once they are loaded."
`(progn `(progn
(defun ,fn () (defun ,fn ()
(let (custom--inhibit-theme-enable) (let (custom--inhibit-theme-enable)
(dolist (theme (doom-enlist (or ,theme 'doom))) (dolist (theme (doom-enlist (or ,theme 'user)))
(when (or (memq theme '(user doom)) (when (or (eq theme 'user)
(custom-theme-enabled-p theme)) (custom-theme-enabled-p theme))
(apply #'custom-theme-set-faces theme (apply #'custom-theme-set-faces theme
(mapcan #'doom--custom-theme-set-face (mapcan #'doom--custom-theme-set-face
@ -52,7 +52,7 @@ 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 simplified face format, and takes care of load order issues, so you can use
doom-themes' API without worry." doom-themes' API without worry."
(declare (indent defun)) (declare (indent defun))
`(custom-theme-set-faces! 'doom ,@specs)) `(custom-theme-set-faces! 'user ,@specs))
;;;###autoload ;;;###autoload
(defun doom/reload-theme () (defun doom/reload-theme ()

View file

@ -567,10 +567,6 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
;; ;;
;;; Theme & font ;;; Theme & font
;; Use a pseudo theme to store internal and user faces + custom.el settings
;; without risk of them being written to `custom-file'.
(custom-declare-theme 'doom nil)
;; User themes should live in ~/.doom.d/themes, not ~/.emacs.d ;; User themes should live in ~/.doom.d/themes, not ~/.emacs.d
(setq custom-theme-directory (concat doom-private-dir "themes/")) (setq custom-theme-directory (concat doom-private-dir "themes/"))
@ -592,16 +588,13 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
(set-fontset-font t 'unicode font)) (set-fontset-font t 'unicode font))
(when doom-unicode-font (when doom-unicode-font
(set-fontset-font t 'unicode doom-unicode-font)))) (set-fontset-font t 'unicode doom-unicode-font))))
;; Changes to a theme don't take effect immediately if the theme isn't `user', (apply #'custom-set-faces
;; so we must force it to.
(let (custom--inhibit-theme-enable)
(apply #'custom-theme-set-faces 'doom
(append (when doom-font (append (when doom-font
`((fixed-pitch ((t (:font ,doom-font)))))) `((fixed-pitch ((t (:font ,doom-font))))))
(when doom-serif-font (when doom-serif-font
`((fixed-pitch-serif ((t (:font ,doom-serif-font)))))) `((fixed-pitch-serif ((t (:font ,doom-serif-font))))))
(when doom-variable-pitch-font (when doom-variable-pitch-font
`((variable-pitch ((t (:font ,doom-variable-pitch-font))))))))) `((variable-pitch ((t (:font ,doom-variable-pitch-font))))))))
(cond (cond
(doom-font (doom-font
;; 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,
@ -620,15 +613,12 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
(defun doom-init-theme-h (&optional frame) (defun doom-init-theme-h (&optional frame)
"Load the theme specified by `doom-theme' in FRAME." "Load the theme specified by `doom-theme' in FRAME."
(if doom-theme (when (and doom-theme (not (custom-theme-enabled-p doom-theme)))
(unless (custom-theme-enabled-p doom-theme)
;; Fix #1397: if `doom-init-theme-h' is used on `after-make-frame-functions' ;; Fix #1397: if `doom-init-theme-h' is used on `after-make-frame-functions'
;; (for daemon sessions), the new frame must be focused to ensure the theme ;; (for daemon sessions), the new frame must be focused to ensure the theme
;; loads correctly. ;; loads correctly.
(with-selected-frame (or frame (selected-frame)) (with-selected-frame (or frame (selected-frame))
(load-theme doom-theme t))) (load-theme doom-theme t))))
;; Ensure custom faces apply and have highest precendence
(enable-theme 'doom)))
(defadvice! doom--load-theme-a (orig-fn theme &optional no-confirm no-enable) (defadvice! doom--load-theme-a (orig-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'."
@ -645,9 +635,7 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
(when (and (not no-enable) (custom-theme-enabled-p theme)) (when (and (not no-enable) (custom-theme-enabled-p theme))
(setq doom-theme theme) (setq doom-theme theme)
(put 'doom-theme 'previous-themes last-themes) (put 'doom-theme 'previous-themes last-themes)
(doom-run-hooks 'doom-load-theme-hook) (doom-run-hooks 'doom-load-theme-hook))))))
;; `doom' must have precedence
(enable-theme 'doom))))))
;; ;;