1

Something turned hl-line-mode on, which is painful to look at with my color theme.

I've added this to my .emacs

(hl-line-mode -1)
(global-hl-line-mode -1)

to no avail.

I've tried commenting out everything in my .emacs, but the highlighting still happens.

I can disable it with

M-x hl-line-mode

but I need to do that every time I visit a file.

How can I find out what's enabling it, and how can i disable it for good?

  • 2
    Start with no init file (emacs -Q) and recursively bisect it to isolate the code. – Dan Aug 2 '17 at 10:06
  • @Dan Well, w/o even bisecting anything (let alone recursively ;)) a plain emacs WILL turn hl-line on in some places, most notably in recentf-open-files, where it is not only non-de-activatable, but also buggy :( So, yeah. – yPhil Aug 2 '17 at 11:12
  • @Dan This does disable it, so there must be something else other than .emacs being run at startup. I'll look. – cangrejo Aug 2 '17 at 11:13
  • 1
    @yPhil Well, I just grepped and removed every mention of hl-line-mode from my packages in .emacs.d/elpa and nothing, still highlighting. Not fun. – cangrejo Aug 2 '17 at 11:37
  • 2
    In that case: (1) If the problem goes away also when you start with emacs -q (lowercase) then recursively bisect your init file to find the culprit. (2) If the problem does not go away with emacs -q but it does go away with emacs -Q then check site-run-file etc. - something is going wrong with your site's installation of Emacs. See the Emacs manual, node Init File. – Drew Aug 3 '17 at 13:34
0

I actually was never able to find the culprit, but I got rid of it (at least mostly) nonetheless.

I realized it was not happening on all modes, so I ended up adding a hook for the ones it does show up in that I use the most. Perhaps it's a bit dirty, but it did the trick.

In case anyone's interested, this is what I put in my init file (notice the nil instead of a -1):

(add-hook 'python-mode-hook
  (lambda ()
    (setq hl-line-mode nil)))

(add-hook 'emacs-lisp-mode-hook
  (lambda ()
    (setq hl-line-mode nil)))
| improve this answer | |
  • Re: "I actually was never able to find the culprit". Did you try both emacs -Q and emacs -q to find out if it was your personal configuration or the system installation? – Omar Oct 5 '18 at 1:13
  • Yes. It goes away with both options, but I didn't find any package that set it on that I could neutralize. – cangrejo Oct 5 '18 at 7:17
0

Rather than disable it, you could update its color using set-face-attribute.

The command describe-face shows the color of the thing at point and its inheritance structure. I found it helpful to give this command a permanent keybinding:

(global-set-key (kbd "C-h j") 'describe-face)

The list-colors command shows built in color names relative to your current theme. You can use these together with set-face-attribute to find a color that works for you.

I use the global-hl-line-mode with the tango-dark theme whose default highlight is bright yellow.

(load-theme 'tango-dark)    
(global-hl-line-mode 1)

 ;; Define tolerable highlighting color
 (set-face-attribute 'highlight nil :background "#3e4446" :foreground 'unspecified)

This is what the above lines look like:

Changing faces

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.