7

I use hl-line-mode and I really like the built-in misterioso theme. However, the way that lines are highlighted with this theme cancels out syntax highlighting or any other properties of the highlighted lines, as can be seen in this screenshot. enter image description here

How can I keep the highlighting the same color, but avoid covering up the face properties of the highlighted text? I would be willing to compromise and change the color if necessary, but that doesn't seem to be the issue. I have tried changing the color, but still get the same effect. I have also tried this solution, but only succeeded in getting rid of highlighting altogether.

This question seems to be the same or similar to mine, but I am honestly not sure if it is the same. I tried the solution suggested there but couldn't get it to work. Rather than having a discussion in the comments of that question, I thought I would ask a new one, but my feelings will not be hurt if this gets marked as duplicate.

elethan
  • 4,755
  • 3
  • 29
  • 56
  • I don't think the question you link to is a duplicate because it deals with the overriding of the background, while you're dealing with the overriding of the foreground. – PythonNut Feb 27 '16 at 05:49
  • @PythonNut: Seems like the same question to me, whether it is foreground or background. I'd say you should consider adding your answer to that question (swapping foreground & background) and this one should be closed as a duplicate. But this one might be expressed more clearly - not sure what's more kosher in such a case. – Drew Feb 27 '16 at 07:20
  • Possible duplicate of [hl-line-mode hide background, how to avoid this?](http://emacs.stackexchange.com/questions/10445/hl-line-mode-hide-background-how-to-avoid-this) – Drew Feb 27 '16 at 07:20

1 Answers1

5

Basically, the hl-line face is defining a :foreground property, which is overriding the other foreground colors in your theme.

misterioso defines hl-line in terms of highlight using inheritance, and because of an awkward issue (which I asked about here), it's not possible AFAIK to directly inherit from a face, and override one of the properties to be unset.

So instead, you'll need something like this:

(set-face-attribute 'hl-line nil
                    :inherit nil
                    :background (face-background 'highlight))

This may not be as clean as a hypothetical solution that could preserve the inheritance, but it works.


As noted by Stefan, another solution would be to remove the foreground from the highlight face, which would fix this issue for other types of highlights as well.

(set-face-foreground 'highlight nil)
PythonNut
  • 10,243
  • 2
  • 29
  • 75