Skip to content

Commit

Permalink
use existing hooks instead of advice
Browse files Browse the repository at this point in the history
  • Loading branch information
laishulu committed Dec 25, 2024
1 parent b83b8db commit cee7e94
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sis.el
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ TYPE: TYPE can be \\='native, \\='w32, \\='emp, \\='macism, \\='im-select,
;;
;; Following codes are mainly about cursor color mode
;;
(defun sis--reset-default-cursor-color ()
(defun sis--reset-default-cursor-color (&rest _)
"Reset default cursor color to nil."
(setq sis-default-cursor-color nil))

Expand Down Expand Up @@ -701,13 +701,15 @@ way."
;; auto refresh input source
(unless (eq sis-external-ism 'native)
(sis--try-enable-auto-refresh-mode))
(advice-add 'enable-theme :after #'sis--reset-default-cursor-color)
(add-hook 'enable-theme-functions #'sis--reset-default-cursor-color)
(add-hook 'disable-theme-functions #'sis--reset-default-cursor-color)
(advice-add 'set-cursor-color :filter-args #'sis--set-cursor-color-advice)
(add-hook 'sis-change-hook #'sis--update-cursor-color))
(; turn off the mode
(not sis-global-cursor-color-mode)
(sis--try-disable-auto-refresh-mode)
(advice-remove 'enable-theme #'sis--reset-default-cursor-color)
(remove-hook 'enable-theme-functions #'sis--reset-default-cursor-color)
(remove-hook 'disable-theme-functions #'sis--reset-default-cursor-color)
(advice-remove 'set-cursor-color #'sis--set-cursor-color-advice)
(remove-hook 'sis-change-hook #'sis--update-cursor-color))))

Expand Down

0 comments on commit cee7e94

Please sign in to comment.