Skip to content

Commit

Permalink
editor/evil: simplify cursor color change logic
Browse files Browse the repository at this point in the history
Fixes race conditions where the cached cursor's color doesn't match the
loaded theme's.
  • Loading branch information
hlissner committed May 28, 2021
1 parent a600e59 commit 69ea5c2
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions modules/editor/evil/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,11 @@ directives. By default, this only recognizes C directives.")
("^\\*Command Line" :size 8)))))

;; Change the cursor color in emacs state. We do it this roundabout way
;; instead of changing `evil-default-cursor' (or `evil-emacs-state-cursor') so
;; it won't interfere with users who have changed these variables.
(defvar +evil--default-cursor-color "#ffffff")
(defvar +evil--emacs-cursor-color "#ff9999")

(add-hook! 'doom-load-theme-hook
(defun +evil-update-cursor-color-h ()
(setq +evil--default-cursor-color (face-background 'cursor)
+evil--emacs-cursor-color (face-foreground 'warning))))

;; to ensure changes in theme doesn't break these colors.
(defun +evil-default-cursor-fn ()
(evil-set-cursor-color +evil--default-cursor-color))
(evil-set-cursor-color (face-background 'cursor)))
(defun +evil-emacs-cursor-fn ()
(evil-set-cursor-color +evil--emacs-cursor-color))
(evil-set-cursor-color (face-foreground 'warning)))

(setq-hook! 'after-change-major-mode-hook evil-shift-width tab-width)

Expand Down

0 comments on commit 69ea5c2

Please sign in to comment.