]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow hl-line-mode so work when global-hl-line-mode is active
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 20 Sep 2022 11:55:39 +0000 (13:55 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 20 Sep 2022 11:56:19 +0000 (13:56 +0200)
* lisp/hl-line.el (hl-line-mode): Allow switching off the global
mode in the current buffer (bug#51580).

lisp/hl-line.el

index e5ca6819f0d149a24664236371a01553d2392a0a..693c94eea8cea3a127d2fd974cca9a741f1a557a 100644 (file)
@@ -154,6 +154,12 @@ non-selected window.  Hl-Line mode uses the function
 When `hl-line-sticky-flag' is nil, Hl-Line mode highlights the
 line about point in the selected window only."
   :group 'hl-line
+  ;; If the global mode is switched on, then `M-x hl-line-mode' should
+  ;; switch the mode off in this buffer.
+  (when global-hl-line-mode
+    (setq hl-line-mode nil)
+    (setq-local global-hl-line-mode nil)
+    (global-hl-line-unhighlight))
   (if hl-line-mode
       (progn
         ;; In case `kill-all-local-variables' is called.