How to customize a face on Emacs, but only when hl-line is active?

1k Views Asked by At

I am using Emacs 24, console (8 colors) with the Solarized theme.

Emacs 24 with Solarized theme

I want to make the comments less intrusive using:

(set-face-foreground 'font-lock-comment-delimiter-face "black")
(set-face-foreground 'font-lock-comment-face "black")

That way the comments would be colored with the same color as the hl-line face we can see on the picture. However, when moving to a line containing comments, I would like them to be inverted (black background from the hl-line, normal foreground instead of black) so I can still read them.

2

There are 2 best solutions below

0
On

As an alternative, you can also temporarily hide comments. See command hide/show-comments-toggle in library hide-comnt.el. Bind it to a handy key --- pretty simple.

7
On

Please see the code in the attached link: Emacs colors. why it is gray on current line? zenburn theme