Function: global-hl-line-mode
global-hl-line-mode is an autoloaded, interactive and byte-compiled
function defined in hl-line.el.gz.
Signature
(global-hl-line-mode &optional ARG)
Documentation
Toggle line highlighting in all buffers (Global Hl-Line mode).
If global-hl-line-sticky-flag is non-nil, Global Hl-Line mode
highlights the line about the current buffer's point in all live
windows.
If global-hl-line-sticky-flag is customized to window,
then instead of highlighting the line with buffer's point,
this mode highlights the line with window's point that might differ from
the buffer's point when the buffer is displayed in multiple windows.
In this case this mode uses the function
global-hl-line-window-redisplay on pre-redisplay-functions.
Global-Hl-Line mode uses the function global-hl-line-highlight
on post-command-hook.
This is a global minor mode. If called interactively, toggle the
Global Hl-Line mode mode. If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.
If called from Lisp, toggle the mode if ARG is toggle. Enable the
mode if ARG is nil, omitted, or is a positive number. Disable the mode
if ARG is a negative number.
To check whether the minor mode is enabled in the current buffer,
evaluate (default-value \=global-hl-line-mode)'.
The mode's hook is called both when the mode is enabled and when it is disabled.
Probably introduced at or before Emacs version 21.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/hl-line.el.gz
;;;###autoload
(define-minor-mode global-hl-line-mode
"Toggle line highlighting in all buffers (Global Hl-Line mode).
If `global-hl-line-sticky-flag' is non-nil, Global Hl-Line mode
highlights the line about the current buffer's point in all live
windows.
If `global-hl-line-sticky-flag' is customized to `window',
then instead of highlighting the line with buffer's point,
this mode highlights the line with window's point that might differ from
the buffer's point when the buffer is displayed in multiple windows.
In this case this mode uses the function
`global-hl-line-window-redisplay' on `pre-redisplay-functions'.
Global-Hl-Line mode uses the function `global-hl-line-highlight'
on `post-command-hook'."
:global t
:group 'hl-line
(if global-hl-line-mode
(cond
((eq global-hl-line-sticky-flag 'window)
(add-hook 'pre-redisplay-functions
#'global-hl-line-window-redisplay))
(t
;; In case `kill-all-local-variables' is called.
(add-hook 'change-major-mode-hook #'global-hl-line-unhighlight)
(global-hl-line-highlight-all)
(add-hook 'post-command-hook (if (eq global-hl-line-sticky-flag 'all)
#'global-hl-line-highlight-all
#'global-hl-line-highlight))))
(cond
((eq global-hl-line-sticky-flag 'window)
(remove-hook 'pre-redisplay-functions
#'global-hl-line-window-redisplay)
(walk-windows (lambda (window)
(redisplay--unhighlight-overlay-function
(window-parameter window 'hl-line-overlay))
(set-window-parameter window 'hl-line-overlay nil))
t t))
(t
(global-hl-line-unhighlight-all)
(remove-hook 'post-command-hook #'global-hl-line-highlight)
(remove-hook 'post-command-hook #'global-hl-line-highlight-all)
(remove-hook 'change-major-mode-hook #'global-hl-line-unhighlight)))))