1

I have the following line turning hl-line-mode on globally in my init file:

(global-hl-line-mode)

Most of the time, that's how I like it. But sometimes I want to turn it off. I'd hoped that I could somehow override the global setting with a buffer-local one, by running hl-line-mode with a negative prefix argument. This does turn off the highlight for about a second, then it just comes back. I can, of course, disable global-hl-line-mode instead, but is there a way to do a buffer or window local override of this setting?

Update Kudos to @lawlist for the necessary mechanics. I bound this up in a little function and am quite happy with it.

(defun ivan/local-toggle-hl-line ()
  "Toggle line highlighting in current buffer"
  (interactive)
  (setq-local global-hl-line-mode
              (null global-hl-line-mode)))

Dedicating it to the same keybinding that iTerm2 uses for the same sort of thing ⌥⌘;

Drew
  • 75,699
  • 9
  • 109
  • 225
ivan
  • 1,928
  • 10
  • 20
  • 2
    How about?: `(setq-local global-hl-line-mode nil)` See -- **how to disable hl-line feature in specified mode**: http://stackoverflow.com/questions/9990370/how-to-disable-hl-line-feature-in-specified-mode – lawlist Aug 03 '16 at 14:29
  • Very closely related to http://emacs.stackexchange.com/q/9747/115 ? – Kaushal Modi Aug 03 '16 at 16:09
  • @lawlist That seems pretty counter-intuitive to me (a local global setting), but it works! Thank you – ivan Aug 04 '16 at 00:20

0 Answers0