I'm trying to change the mode-line face box attribute to be the same color as the evil emacs state face, obviously updating it each time the mode changes. I've seen some things about using a post-command-hook, but frankly am not sure how to do so. I'm using spaceline, so hopefully there would be a way to get the current evil state face as well, or else it would get even messier. I'm not sure if such a thing is even possible.

  • 1
    I wonder if spacemacs deserves to be mentioned in the question title, since it's directly involved in the answer to the question.
    – PythonNut
    Jul 30, 2016 at 22:18
  • I don't really understand this question, since spacemacs's mode line changes its color according to evil's state.
    – user17303
    Oct 23, 2017 at 11:08

1 Answer 1


This is how Spaceline chooses the faces in the modeline:


See also the preceding section about the highlight face.

You can override the default with an arbitrary function of your choice, so there's no limit to creativity. It sounds like you want to make one new face for each of the four basic faces and for each of the evil states, set the box attribute (and other attributes) according to how you make them, and write a function that picks from these faces according to however you'd like to do it. You can get the evil state from evil-state variable, for example.

For example, here is how Spaceline defines the highlight faces for each evil state. I would link you to the function where Spaceline chooses which one to use, too, but Stackexchange won't let me post more than two links, so you're going to have to find that one on your own (it's a few lines further down).

For example, here is a function that chooses based on active and evil state:

(defun my-face-func (face active)
  (let ((act (if active "active" "inactive")))
    (intern (format "my-face-%s-%s-%s" face act evil-state))))

(setq spaceline-face-func 'my-face-func)

Then all you need is to define all the faces my-face-X-Y-Z where

  • X is one of face1, face2, line and highlight;
  • Y is one of active and inactive; and
  • Z is one of normal, insert, visual, and so on.

Of course that's a lot of faces, which is partially why the default implementation of that face function picks from a more limited set.

  • Hmmm... Is there really no way to grab the current face of the evil emacs mode? I feel like spaceline must have that somewhere. I've been looking for a while but can't seem to find it. May 30, 2016 at 21:40
  • I'm not sure what you mean by that exactly? Spacemacs uses the face spacemacs-emacs-face to highlight the modeline in emacs state, if that's what you mean. (Similarly named faces for the other states.) May 30, 2016 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.