Using Emacs 26.3. I made a theme file. If I change the theme, then restart Emacs the change is not applied. I have to close Emacs a second time, and then only on the second start up does the change take effect.
init.el
:
(load-theme 'foo t)
(package-install-file (expand-file-name "foo-theme.el" user-emacs-directory))
Within the theme:
... other stuff ...
(custom-theme-set-faces
'foo
;; DEFAULT
`(default ((,class (:foreground "#FFFFFF" :background "#000000" :distant-foreground "#000000"))))
If I perform the following:
- Comment out the
default
face infoo-theme.el
- Save
foo-theme.el
- Close Emacs.
- Open Emacs, open
foo-theme.el
, I see the change is still there but the face change was not applied to the default face (Emacs looks the same). - Close Emacs.
- Open Emacs, and now I see that
foo-theme
has been applied correctly (default face looks as it should), and themy-theme.el
file remains the same.
Why does it not apply correctly on the next start up of Emacs? How to fix it to load the theme correctly (maybe it is caching it somewhere)?
init.el
are weird. Where do they come from? E.g. you shouldn't re-package-install every time. And you shouldn't have Elisp files insideuser-emacs-directory
(you can put them inside a subdirectory ofuser-emacs-directory
on the other hand). – Stefan Mar 25 '20 at 13:02lisp ;; dummy theme ;; http://emacsfodder.github.io/blog/notes-on-deftheme/ (deftheme foo) (custom-theme-set-faces 'foo '(default ((t (:foreground "#00feff" :background "black")))) '(fringe ((t (:background "#00ff00"))))) (provide-theme 'foo)
In addition, I think thatpackage-install-file
might not be necessary.(load-theme 'foo t)
should be sufficient (assumingcustom-theme-directory
is set properly). What version of emacs are – Haskell Curry Mar 24 '20 at 23:50init.el
are from me!foo-theme.el
is my own custom theme placed in my .emacs.d (part of my dot emacs git check out). Why not put .el files within~/.emacs.d
, is that not what it is for? – Mar 26 '20 at 09:53.emacs.d/<foo>.el
is often used by package<foo>
to keep some internal information (like a history of use). Always put your Elisp files in some subdirectory if you want to use.emacs.d
, e.g.~/.emacs.d/myfiles/<foo>.el
. – Stefan Mar 26 '20 at 15:18