Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: hl-line-mode conflicts with highlight-phrase

Tags:

emacs

I highlight current line by evaluating:

(hl-line-mode)

It could also be set globally:

(global-hl-line-mode nil)

The problem is that this way line highlighting overrides highlight-phrase. So my question is: "how to highlight both current line and a given phrase in this line?"

like image 743
Adobe Avatar asked Jul 03 '11 10:07

Adobe


2 Answers

Both highlight-phrase and hl-line apply faces that have a background color set. hl-line wins because it uses an overlay, and overlays always override text properties, which highlight-phrase uses. I suggest that you work around this by customizing the hi-yellow face to use a bright foreground color instead of a background color, or even a box.

like image 172
sanityinc Avatar answered Nov 14 '22 12:11

sanityinc


So here's some, definetly not ideal, solution. Do:

M-x customize-face

emacs then asks you which one, and I did

hl-line

Then I turned off "inherit" flag (the last one), and turned on the "foreground" flag, - it was saying "black" - I made it red. After that You should save it all at the top of the page - either - for this seccion only, or for future sessions too.

That's it! This way current line text arrears of red font, while highlight-phrase highlights the phrase with yellow.

like image 2
Adobe Avatar answered Nov 14 '22 12:11

Adobe