editor/evil: use evil-set-cursor-color

set-cursor-color causes an expensive redraw. Plugins like treemacs may
silently change window focus, triggering these calls and causing
freezing. We use evil-set-cursor-color instead, which avoids
set-cursor-color unless the cursor's color has changed.
This commit is contained in:
Henrik Lissner 2019-05-17 20:45:23 -04:00
parent 571e7bd527
commit f7b75a7d68
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -54,18 +54,22 @@ line with a linewise comment.")
("^\\*Command Line" :size 8)))) ("^\\*Command Line" :size 8))))
(add-hook 'doom-init-modules-hook #'+evil|init-popup-rules) (add-hook 'doom-init-modules-hook #'+evil|init-popup-rules)
;; Change the cursor color in emacs mode ;; Change the cursor color in emacs state. We do it this roundabout way
(defvar +evil--default-cursor-color ;; instead of changing `evil-default-cursor' (or `evil-emacs-state-cursor') so
(or (ignore-errors (frame-parameter nil 'cursor-color)) ;; it won't interfere with users who have changed these variables.
"#ffffff")) (defvar +evil--default-cursor-color "#ffffff")
(defvar +evil--emacs-cursor-color "#ff9999")
(defun +evil-default-cursor () (set-cursor-color +evil--default-cursor-color))
(defun +evil-emacs-cursor () (set-cursor-color (face-foreground 'warning)))
(defun +evil|update-cursor-color () (defun +evil|update-cursor-color ()
(setq +evil--default-cursor-color (face-background 'cursor))) (setq +evil--default-cursor-color (face-background 'cursor)
+evil--emacs-cursor-color (face-foreground 'warning)))
(add-hook 'doom-load-theme-hook #'+evil|update-cursor-color) (add-hook 'doom-load-theme-hook #'+evil|update-cursor-color)
(defun +evil-default-cursor ()
(evil-set-cursor-color +evil--default-cursor-color))
(defun +evil-emacs-cursor ()
(evil-set-cursor-color +evil--emacs-cursor-color))
(defun +evil|update-shift-width () (defun +evil|update-shift-width ()
(setq evil-shift-width tab-width)) (setq evil-shift-width tab-width))
(add-hook 'after-change-major-mode-hook #'+evil|update-shift-width t) (add-hook 'after-change-major-mode-hook #'+evil|update-shift-width t)