1

I use something like this to control the background color of my selected text:

(region ((t (:background ,green))
            (t :inverse-video t)))

However some foreground colors don't go well with my background color and the text becomes hard to read. So I experimented with different background colors for region, but the results have not been satisfactory.

Now I wish for this behavior:

Interchange the background and foreground colors on my selected text.

The following images are for illustration of what I want:

  1. Without Selection:

without highlighting

  1. With Selection:

with highlighting

With this I feel, I will be able to demarcate the selected text all the while retaining my syntax highlighting along with readability.

How do I accomplish this within Emacs?

Drew
  • 75,699
  • 9
  • 109
  • 225
Inspired_Blue
  • 278
  • 2
  • 12

1 Answers1

0

Perhaps I don't understand. Just customizing face region to (only) use inverse-video gives you what you're asking for, as far as I can see. So just get rid of the imposition of a green background:

enter image description here

Drew
  • 75,699
  • 9
  • 109
  • 225
  • That was really simple! Earlier I had tried `C-h v` to describe `inverse-video`, but I never quite understood what `inverse-video` did. A follow up question: How can I do some conditional formatting? For example I do not want inverse-video if the foreground color is white. If my foreground ground color is white I want to manually specify which foreground and background to use when highlighting selected text. – Inspired_Blue Oct 01 '21 at 05:07
  • Post your follow-up question as a separate question, please. – Drew Oct 01 '21 at 17:21
  • I have posted the follow-up question [here](https://emacs.stackexchange.com/questions/68760/conditional-formatting-foreground-and-background-when-highlighting-selected-text). Thanks! – Inspired_Blue Oct 01 '21 at 17:52