How do I change the highlight color for selected text with Emacs / deftheme?
EmacsEmacs Problem Overview
I'm using Emacs 24; I've installed the zenburn theme, which is great, except I cannot see the selection highlight easily with the highlight color provided by zenburn:
By "selection" color, I mean the color of text that I've selected by setting a mark (C-space
and moving the cursor to select text).
For the life of me, I cannot figure out how to change it. I've tried changing every combination of highlight
, selection
, etc.. that I can think of in zenburn-theme.el
, but nothing seems to change it.
*For sanity's sake, I've tried changing other colors in the theme to make sure Emacs is loading the file properly - it is - those changes work.
I would have especially thought that changing highlight
would work, but no customizations to the highlight
line seem to work:
;;;; Built-in
;;;;; basic coloring
...
`(highlight ((t (:background ,zenburn-bg-05 :foreground ,zenburn-yellow))))
How can I change the selection color?
Emacs Solutions
Solution 1 - Emacs
What you're looking for is the region
face. For example:
(set-face-attribute 'region nil :background "#666")
Solution 2 - Emacs
In addition to tungd's solution. You could also then change the font color to make it more readable. E.g. to white
(set-face-attribute 'region nil :background "#666" :foreground "#ffffff")
Solution 3 - Emacs
You can use the customize interface.
M-x customize-face
When prompted for which face, enter region
. Then you'll see
something like:
Using customize makes it easy to experiment with lots of colors. Try
clicking [ Choose ]
to access the color-picker), then
[ Apply and Save ]
. It also nicely organizes your customizations
into a single file (rather than further polluting your init.el
).