From f7b75a7d68ea8200948e2c9cfb4c1ab62bfda4fb Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 17 May 2019 20:45:23 -0400 Subject: [PATCH] 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. --- modules/editor/evil/config.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/editor/evil/config.el b/modules/editor/evil/config.el index eae78c21a..1d560ee68 100644 --- a/modules/editor/evil/config.el +++ b/modules/editor/evil/config.el @@ -54,18 +54,22 @@ line with a linewise comment.") ("^\\*Command Line" :size 8)))) (add-hook 'doom-init-modules-hook #'+evil|init-popup-rules) - ;; Change the cursor color in emacs mode - (defvar +evil--default-cursor-color - (or (ignore-errors (frame-parameter nil 'cursor-color)) - "#ffffff")) - - (defun +evil-default-cursor () (set-cursor-color +evil--default-cursor-color)) - (defun +evil-emacs-cursor () (set-cursor-color (face-foreground 'warning))) + ;; 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") (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) + (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 () (setq evil-shift-width tab-width)) (add-hook 'after-change-major-mode-hook #'+evil|update-shift-width t)