Changing highlight line color in emacs
Asked Answered
T

2

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

Torsion answered 17/7, 2013 at 13:49 Comment(0)
A
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)
Andrien answered 24/10, 2013 at 1:20 Comment(4)
That's a no-go. I am also using tomorrow-theme (github.com/chriskempson/tomorrow-theme), so that might be influential. In any case, your described method doesn't work.Armendariz
@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.Andrien
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 .Armendariz
I think the keep-syntax-hilighting command should be (set-face-foreground 'hl-line nil). Is that a typo?Any
L
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).

Leventis answered 17/7, 2013 at 14:4 Comment(6)
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?Torsion
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...Leventis
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.Torsion
M-x describe-face will help see which face is used to highlight a particular character.Scopas
@BozhidarBatsov: Thanks, that was smartparens.el (fixed). How could I make it keep the syntax highlighting?(See my previous comment)Torsion
@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).Leventis

© 2022 - 2024 — McMap. All rights reserved.