From d989fc89972a7b2c1bef9000cca275ce85bd69c6 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 20 Sep 2022 13:55:39 +0200 Subject: [PATCH] Allow hl-line-mode so work when global-hl-line-mode is active * lisp/hl-line.el (hl-line-mode): Allow switching off the global mode in the current buffer (bug#51580). --- lisp/hl-line.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lisp/hl-line.el b/lisp/hl-line.el index e5ca6819f0d..693c94eea8c 100644 --- a/lisp/hl-line.el +++ b/lisp/hl-line.el @@ -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. -- 2.39.2