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?

cangrejo
  • 131
  • 4
  • 2
    Start with **no** init file (`emacs -Q`) and recursively bisect it to isolate the code. – Dan Aug 02 '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 02 '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 02 '17 at 11:13
  • @yPhil I guess this is the time when I really learn how emacs init works from head to toe and say goodbye to about half of my headaches. – cangrejo Aug 02 '17 at 11:14
  • @broncoAbierto did you try to `recentf-open-files`? hard-coded `hl-line-mode` ; No way to turn it off :( – yPhil Aug 02 '17 at 11:16
  • 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 02 '17 at 11:37
  • yPhil: which version of Emacs? In Emacs 25.2.1 `recentf-open-files` (or indeed `recentf.el`) contains no call to `hl-line-mode` or any other instance of the text "hl-line". – phils Aug 02 '17 at 12:34
  • I don't yet see any mention of starting Emacs with `emacs -Q`. I see only mention of "a plain emacs". Start with `emacs -Q` (no init file and no site file), to see if you can reproduce the problem. If the problem is from `recentf.el`, without your doing anything, then consider filing a bug against that: `M-x report-emacs-bug`. – Drew Aug 02 '17 at 13:58
  • @Drew I have started with `emacs -Q` and the problem goes away, but I still haven't been able to find what triggers it. – cangrejo Aug 03 '17 at 08:04
  • 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](http://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html). – Drew Aug 03 '17 at 13:34

2 Answers2

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)))
cangrejo
  • 131
  • 4
  • 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 05 '18 at 01: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 05 '18 at 07: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

Lorem Ipsum
  • 4,327
  • 2
  • 14
  • 35
  • 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). – Lorem Ipsum Aug 26 '21 at 19:12