2015-12-22

Evil Mode hack for a colorful mode line

Intro

After trying out Spacemacs for about a week (and failing - too much old configuration to "convert") I am trying out Evil Mode by itself. It goes forward, slowly, step by step.

One thing I have been a bit annoyed with was how the different states are visualized. Being a Evil/Vim newbie I want to see, clearly, in which state/mode I am in.

Today I decided to do something about it and here is how my Emacs looks now:

Normal state


Insert state


Emacs state




How it was done

I could not find any good entry points for customizing the mode line with respect to the Evil Mode states, but I found the function (evil-generate-mode-line-tag) that generates the part of the mode line that comes from Evil Mode. I simply made a copy of it and changed it to add also a face attribute to the mode line, and let the face be different depending on the mode.

The code

Copy the code below and save it in a file called my-evil-hacks.el.

After this you need to make sure to load this file after you have loaded Evil mode for the first time. One way to achieve this is to put the following snippet in your .emacs or init.el file:
(with-eval-after-load "evil"
  (load "my-evil-hacks"))
Enjoy!

No comments: