For some reason, I need to manually update the custom-theme-load-path
list after every update of a theme like smart-mode-line
or leuven-theme
. Looking for a solution, I came across this SO post. Here is the solution from that post (with slight modification):
;; Ensure that the custom-theme-load-path has all the theme paths added
;; Source: https://stackoverflow.com/a/15381087/1219634
(require 'dash)
(require 's)
(-each
(-map
(lambda (item)
(format (concat elpa-dir "/%s") item))
(-filter
(lambda (item)
(or (s-contains? "theme" item)
(s-contains? "smart-mode-line" item)))
(directory-files elpa-dir)))
(lambda (item)
(add-to-list 'custom-theme-load-path item)))
The above snippet works great and it updates custom-theme-load-path
. The catch is that every time I load a theme using load-theme
, the custom-theme-load-path
resets to the value set by Customize. I have verified this behavior by putting (message "%s" custom-theme-load-path)
before and after the call to (load-theme ..)
.
How can I permanently set the value of custom-theme-load-path
so that load-theme
cannot reset its value?
Here is a workaround I use to avoid this issue (but I'd like to understand why this is happening):
- I have wrapped the above snippet in a function called
update-custom-theme-load-path
. - I call that function right before I call
(load-theme 'leuven t)
custom-theme-load-path
is set in Customize. When you update (viapackage.el
) eitherleuven
orsmart-mode-line
, those packages are no longer oncustom-theme-load-path
?package.el
. I used to manually update the path till I found the above snippet.package-initialize
in yourinit-file
? And/or could you test runningpackage-initialize
after updating the theme, but before loading it?(package-initialize)
. I call it before requiring any of the themes. I also triedC-x C-e
on that just now with the themes updated; but that did not updatecustom-theme-load-path
. Iload
this before requiring any theme/package.