3

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?

10
  • 2
    Start with no init file (emacs -Q) and recursively bisect it to isolate the code.
    – Dan
    Commented Aug 2, 2017 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
    Commented Aug 2, 2017 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
    Commented Aug 2, 2017 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
    Commented Aug 2, 2017 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
    Commented Aug 3, 2017 at 13:34

2 Answers 2

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)))
2
  • 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
    Commented Oct 5, 2018 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
    Commented Oct 5, 2018 at 7:17
-1

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

1
  • For whoever down-voted this, is there something technically incorrect about it? I understand that it doesn't explain how to disable hl-line-mode. However, the problem the OP had was that their hl-line was "painful to look at". This answer addresses that problem. Disabling hl-line simply happens to be another way to address the problem (and is somewhat of an XY issue). Commented Aug 26, 2021 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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