Reputation: 13477
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?"
Upvotes: 10
Views: 1299
Reputation: 8956
Edit: The previous solution that I posted doesn't work, but this one should.
Highlight has two modes, one for font-lock-enabled buffers (which uses font-lock) and one for without (which uses overlay). The solution I found was to simply force highlight to use overlay at all times, and thus have higher priority over hl-line (because shorter overlays have an implicitly higher priority, given the same value of priority
).
To do this I went into hi-lock.el
and replaced every instance of font-lock-fontified
with nil
. Be sure to M-x byte-compile-file
afterwards in order to update hi-lock.elc
.
Upvotes: 2
Reputation: 13477
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.
Upvotes: 2
Reputation: 15212
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.
Upvotes: 6