Closed brongulus closed 1 year ago
I think you are on the right track. I don't change themes myself but I understand there is no theme-change hook. So your advice looks reasonable to me. Perhaps it was not correctly enabled?
Update: Prot (of ef-themes fame) recommends:
(defvar after-enable-theme-hook nil
"Normal hook run after enabling a theme.")
(defun run-after-enable-theme-hook (&rest _args)
"Run `after-enable-theme-hook'."
(run-hooks 'after-enable-theme-hook))
(advice-add 'enable-theme :after #'run-after-enable-theme-hook)
Presumably because load-theme
is too early. Can you test this and let me know?
(advice-add 'enable-theme :after #'run-after-enable-theme-hook)
Presumably because
load-theme
is too early. Can you test this and let me know?
Unfortunately this didn't work either.
Unfortunately this didn't work either.
Did you add kind-icon-reset to after-enable-theme-hook with add-hook?
No, would that make a difference? I tried doing it that way too, didn't work.
(use-package kind-icon
:after nerd-icons
:init
(load "~/.emacs.d/+icons" nil t)
(push 'kind-icon-margin-formatter corfu-margin-formatters)
:custom
(defvar after-enable-theme-hook nil)
(defun run-after-enable-theme-hook (&rest _args)
(run-hooks 'after-enable-theme-hook))
(add-hook 'after-enable-theme-hook #'kind-icon-reset-cache)
:config
(advice-add 'enable-theme :after #'run-after-enable-theme-hook)) ;; FIXME
None of that should go under :custom
in your use-package
, that's strictly for custom set variables.
If you define the enable-theme hooks elsewhere, you can use them in all your packages. I set this up and it works fine:
(use-package custom
:init
(defvar after-enable-theme-hook nil)
(defun run-after-enable-theme-hook (&rest _args)
(run-hooks 'after-enable-theme-hook))
(advice-add 'enable-theme :after #'run-after-enable-theme-hook))
(use-package kind-icon
:after corfu
:custom
(kind-icon-default-face 'corfu-default)
:config
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)
(add-hook 'after-enable-theme-hook #'kind-icon-reset-cache))
Hi, thanks for the great work!
I have an automatic timer for changing themes, however upon theme change the kind-icon still follow the old colorscheme.
I can manually clear the cache by using
kind-icon-reset-cache
, however I was wondering if it is possible to automate that upon invocation ofload-theme
.I tried advising
load-theme
ashowever that wasn't working. Do you have any idea on how I can proceed with this?