Function: hl-line-mode
hl-line-mode is an autoloaded, interactive and byte-compiled function
defined in hl-line.el.gz.
Signature
(hl-line-mode &optional ARG)
Documentation
Toggle highlighting of the current line (Hl-Line mode).
Hl-Line mode is a buffer-local minor mode. If
hl-line-sticky-flag is non-nil, Hl-Line mode highlights the
line about the buffer's point in all windows. Caveat: the
buffer's point might be different from the point of a
non-selected window. Hl-Line mode uses the function
hl-line-highlight on post-command-hook in this case.
When hl-line-sticky-flag is nil, Hl-Line mode highlights the
line about point in the selected window only.
This is a minor mode. If called interactively, toggle the
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 hl-line-mode(var)/hl-line-mode(fun).
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 hl-line-mode
"Toggle highlighting of the current line (Hl-Line mode).
Hl-Line mode is a buffer-local minor mode. If
`hl-line-sticky-flag' is non-nil, Hl-Line mode highlights the
line about the buffer's point in all windows. Caveat: the
buffer's point might be different from the point of a
non-selected window. Hl-Line mode uses the function
`hl-line-highlight' on `post-command-hook' in this case.
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 (and global-hl-line-mode
(eq arg 'toggle))
(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.
(add-hook 'change-major-mode-hook #'hl-line-unhighlight nil t)
(hl-line-highlight)
(setq hl-line-overlay-buffer (current-buffer))
(add-hook 'post-command-hook #'hl-line-highlight nil t))
(remove-hook 'post-command-hook #'hl-line-highlight t)
(hl-line-unhighlight)
(remove-hook 'change-major-mode-hook #'hl-line-unhighlight t)))