Marking The Active Window Redux

Just the other day I wrote about James Dyer’s solution for marking the active window so that it’s immediately obvious which window has focus. In that post, I said that although Dyer’s solution was a good one, I thought that simply having the background color of the active window’s mode line something other than a slightly different shade of gray would work just as well and suit me better.

Ignacio Paz Posse to the rescue. In a comment to the post, he says that changing the background color of the mode line is exactly what he does and added a snippet of code to do just that. Since this is Emacs and since I was, of course, reading the email notification of his comment in it, I simple put the cursor at the end of the code snippet, typed Ctrl+x Ctrl+e, and just like that my active window’s mode line was dark goldenrod and stood out from the other windows.

The background color of my windows are a light tan (oldlace) so goldenrod was, serendipitously, just perfect. The code

(set-face-attribute 'mode-line nil
:foreground "black" :background "dark goldenrod" :box '(:line-width 1 :color "black"))

is simplicity itself. Because of Prot’s video, I assumed that even a simple change like that would be tricky but happily it’s straightforward. In any event, if you want a mode line that sticks out more than the standard dark gray, this is how to do it. You can adjust the color to fit your color scheme.

One more point worth mentioning is how easy it was to test this. As I said, I simply evaluated the code in the email and the changes took place immediately. That’s one of Emacs’ secret powers: if it’s Elisp and it’s in a buffer, you can execute it and see the results immediately without worrying about copying or other applications.

This entry was posted in General and tagged . Bookmark the permalink.