Skip to content

Commit 5af4798

Browse files
authored
Add advice meow--prepare-face to enable-theme instead of load-theme (#488)
* Add advice `meow--prepare-face` to `enable-theme` instead of `load-theme` Add advice `meow--prepare-face` to function `enable-theme` instead of `load-theme`. This will help prepare faces if a theme is enabled with `enable-theme`. The modification does not change the current behavior, because `enable-theme` is called at the end of `load-theme`, and calling `load-theme` also triggers advice on `enable-theme`. * Use a wrapper of `meow--prepare-face` as an advice to `enable-theme` Adding advice `meow--prepare-face` to `enable-theme` instead of `load-theme` (commit 64bdbee) causes `meow--prepare-face` being called twice when a theme is enabled. This commit uses a wrapper of `meow--prepare-face` as the advice. The wrapper calls `meow--prepare-face` only when the theme to enable is `user`.
1 parent 4ab409f commit 5af4798

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

meow-core.el

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ there's no chance for meow to call an init function."
160160
(when (secondary-selection-exist-p)
161161
(meow--cancel-second-selection)))
162162

163+
(defun meow--enable-theme-advice (theme)
164+
"Prepare face if the theme to enable is `user'."
165+
(when (eq theme 'user)
166+
(meow--prepare-face)))
167+
163168
(defun meow--global-enable ()
164169
"Enable meow globally."
165170
(setq-default meow-normal-mode t)
@@ -190,7 +195,7 @@ there's no chance for meow to call an init function."
190195
(setq redisplay-highlight-region-function #'meow--redisplay-highlight-region-function)
191196
(setq redisplay-unhighlight-region-function #'meow--redisplay-unhighlight-region-function))
192197
(meow--prepare-face)
193-
(advice-add 'load-theme :after 'meow--prepare-face))
198+
(advice-add 'enable-theme :after 'meow--enable-theme-advice))
194199

195200
(defun meow--global-disable ()
196201
"Disable Meow globally."
@@ -210,7 +215,7 @@ there's no chance for meow to call an init function."
210215
(setq redisplay-unhighlight-region-function meow--backup-redisplay-unhighlight-region-function))
211216
(unless window-system
212217
(meow-esc-mode -1))
213-
(advice-remove 'load-theme 'meow--prepare-face))
218+
(advice-remove 'enable-theme 'meow--enable-theme-advice))
214219

215220
(provide 'meow-core)
216221
;;; meow-core.el ends here

0 commit comments

Comments
 (0)