34

I installed emacs 24 and also installed prelude and I wanted to change the theme from zenburn to tango-dark. But the color that the line is highlighted is yellow and I don't like that. I want it to be like the gray color in zenburn. tango-dark theme with hl-line enabled(yellow)

zenburn theme with hl-line enabled(dark gray)

What should I do? I prefer not to turn off the hl-line but when I tried that I saw that the space between parentheses () are highlighted with the same yellow color. (In zenburn theme that didn't happen). I also know that this is not part of the tango theme because when I run vanilla emacs(sudo emacs) with tango theme no such highlighting happens. tango-dark theme with hl-mode disabled vanilla emacs with tango-dark theme

Lauraducky
  • 674
  • 11
  • 25
Farzam
  • 1,272
  • 3
  • 14
  • 25

2 Answers2

72

That would be an easy fix if you customize your init file (~/.emacs, ~/.emacs.el, or ~/.emacs.d/init.el)

Turn on hl-line:

(global-hl-line-mode 1)

Set any color as the background face of the current line:

(set-face-background 'hl-line "#3e4446")

To keep syntax highlighting in the current line:

(set-face-foreground 'highlight nil)
soimort
  • 834
  • 1
  • 9
  • 6
  • That's a no-go. I am also using tomorrow-theme (https://github.com/chriskempson/tomorrow-theme), so that might be influential. In any case, your described method doesn't work. – dimitarvp Dec 25 '13 at 22:02
  • 6
    @dimitko That should work in at least Emacs 24, only if you put them in the right place - these could have been overridden by your other configurations or installed packages. – soimort Dec 26 '13 at 04:43
  • 1
    Yep. I wanted to point that out but wasn't clear enough. The way to solve it is, of course, to move your customizations after the loading / activating of your theme, which wasn't the case in my config . – dimitarvp Dec 26 '13 at 10:49
  • I think the keep-syntax-hilighting command should be `(set-face-foreground 'hl-line nil)`. Is that a typo? – mkvoya Mar 26 '17 at 08:16
14

M-x customize-face RET hl-line will help you. Just pick a face you like (you can type the same command with the other theme installed, just to peek the values you like).

juanleon
  • 9,220
  • 30
  • 41
  • Thanks, that solved the first problem but I still have the problem in the third image(yellow highlighting between parentheses. How could I disable that? – Farzam Jul 17 '13 at 14:23
  • 1
    I guess you are using `show-paren-mode` and you have `show-paren-style` set as `expression`. Use M-x customize-variable with show-paren-style and set it to `parenthesis` (or disable the mode if you don't like it). But I might be wrong, and there might be another mode at play... – juanleon Jul 17 '13 at 14:40
  • that didn't help. I think that is disabled. there is also another problem in highlighting line. as you see in zenburn color theme, the syntax highlighting in the line is not changed but in the tango, all the characters are shown in white. How could I change it to look like zenburn. – Farzam Jul 17 '13 at 14:52
  • 1
    `M-x describe-face` will help see which face is used to highlight a particular character. – Bozhidar Batsov Jul 17 '13 at 14:55
  • 1
    @BozhidarBatsov: Thanks, that was smartparens.el (fixed). How could I make it keep the syntax highlighting?(See my previous comment) – Farzam Jul 17 '13 at 20:21
  • 1
    @Farzan, what you need to do is customize-face hl-line and then set the background color of that face, but not the foreground color. In other words, the only "ticked" checkbox should be the background. That way the foreground colors will be "respected" (i.e., not set white). – juanleon Jul 18 '13 at 06:55