Why aren't Syntax Highlighting and Line Highlighting getting along in Emacs 24?
Question
I'm having an issue similar to the one described here:
Disable hl-line in Emacs when using Emacs Starter Kit?
I am using Emacs 24 for OS X ( http://emacsformacosx.com/ ), invoked with the -nw flag to run it in the terminal (so I can have true fullscreen). I started my customizations with the Emacs Starter Kit ( https://github.com/technomancy/emacs-starter-kit ). Most of the things I've added are working well.
However, I have noticed that my syntax highlighting doesn't display when the selected line is highlighted (all the text is the same color). I like the line-highlight
effect but don't want to give up syntax highlighting. Is there any way to accomplish this (particularly in the terminal)?
My syntax/background coloring is done using custom-theme
.
Thanks for your help.
EDIT: I'm using Lion.
Solution
Hmmm, I think you have to customize your hl-line
face using M-x customize-face RET hl-line
. Then make-sure it has no other property (not even the inherit
property) and all it defines is a background-color. The highlighted lines should be highlighted with that background colour, but letting the existing syntax highlighting shine through.
Another approach is to use the "solarized" themes found at https://github.com/sellout/emacs-color-theme-solarized/. These already take care of the issue.
EDIT: Actually you can leave the inherit
property, just make sure that face doesn't override the properties that you want to shine through as syntax highlighting.
OTHER TIPS
Here's a stab in the dark since we don't know what version of OS X you are using. Prior to Lion, Terminal.app did not support 256 colors, so:
- Does it work well in Emacs.app?
- If so, are you running a version of OS X prior to Lion?
- If yes and you don't want to (or can't) upgrade your OS: try using iTerm 2 as your terminal and see how emacs works then.
- If no: perhaps someone else can offer assistance.