From 6c77ed57a52bae098d0fd2ab39928007b369888d Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sat, 25 Nov 2017 20:13:59 +0100 Subject: [PATCH] core: make it possible to define an evil state face without an evil cursor. treemacs: do not define an evil cursor for treemacs. --- .../spacemacs-bootstrap/funcs.el | 24 +++++++++++++++---- layers/+filetree/treemacs/packages.el | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/layers/+distributions/spacemacs-bootstrap/funcs.el b/layers/+distributions/spacemacs-bootstrap/funcs.el index d52b4b789..122f6241e 100644 --- a/layers/+distributions/spacemacs-bootstrap/funcs.el +++ b/layers/+distributions/spacemacs-bootstrap/funcs.el @@ -36,17 +36,31 @@ (defun spacemacs/add-evil-cursor (state color shape) "Define a cursor and face for a new evil state. -An appropriate entry is added to `spacemacs-evil-cursors', as well." +An appropriate entry is added to `spacemacs-evil-cursors', as well. + +For evil states that do not need an evil cursor use +`spacemacs/define-evil-state-face' instead." (add-to-list 'spacemacs-evil-cursors (list state color shape)) + (spacemacs/define-evil-state-face state color) + (set (intern (format "evil-%s-state-cursor" state)) + (list (when dotspacemacs-colorize-cursor-according-to-state color) + shape))) + +(defun spacemacs/define-evil-state-face (state color) + "Define a face for an evil state. +For evil states that also need an entry to `spacemacs-evil-cursors' use +`spacemacs/add-evil-cursor' instead." + ;; this function and `spacemacs/add-evil-cursor' need to be separate because + ;; some states must explicitly *not* have their own evil spacemacs cursor + ;; for example treemacs: it needs no cursor since it solely uses hl-line-mode + ;; and having an evil cursor defined anyway leads to the cursor sometimes + ;; visibly flashing in treemacs buffers (eval `(defface ,(intern (format "spacemacs-%s-face" state)) `((t (:background ,color :foreground ,(face-background 'mode-line) :inherit 'mode-line))) (format "%s state face." state) - :group 'spacemacs)) - (set (intern (format "evil-%s-state-cursor" state)) - (list (when dotspacemacs-colorize-cursor-according-to-state color) - shape))) + :group 'spacemacs))) (defun spacemacs/set-state-faces () (cl-loop for (state color cursor) in spacemacs-evil-cursors diff --git a/layers/+filetree/treemacs/packages.el b/layers/+filetree/treemacs/packages.el index 8b233c8a0..517d68cff 100644 --- a/layers/+filetree/treemacs/packages.el +++ b/layers/+filetree/treemacs/packages.el @@ -34,7 +34,7 @@ "f C-t" #'treemacs-find-file) :config (progn - (spacemacs/add-evil-cursor "treemacs" "MediumPurple1" '(hbar . 0)) + (spacemacs/define-evil-state-face "treemacs" "MediumPurple1") (setq treemacs-follow-after-init t treemacs-width 35 treemacs-position 'left