File: hl-line.el.html

Provides a local minor mode (toggled by M-x hl-line-mode) and a global minor mode (toggled by M-x global-hl-line-mode) to highlight, on a suitable terminal, the line on which point is. The global mode highlights the current line in the selected window only
(except when the minibuffer window is selected). This was
implemented to satisfy a request for a feature of Lesser Editors. The local mode is sticky: it highlights the line about the buffer's point even if the buffer's window is not selected. Caveat: the buffer's point might be different from the point of a non-selected window. Set the variable hl-line-sticky-flag to nil to make the local mode behave like the global mode.

You probably don't really want to use the global mode; if the cursor is difficult to spot, try changing its color, relying on blink-cursor-mode(var)/blink-cursor-mode(fun) or both. The hookery used might affect response noticeably on a slow machine. The local mode may be useful in non-editing buffers such as Gnus or PCL-CVS though.

An overlay is used. In the non-sticky cases, this overlay is active only on the selected window. A hook is added to post-command-hook to activate the overlay and move it to the line about point.

You could make variable global-hl-line-mode(var)/global-hl-line-mode(fun) buffer-local and set it to nil to avoid highlighting specific buffers, when the global mode is used.

By default the whole line is highlighted. The range of highlighting can be changed by defining an appropriate function as the buffer-local value of hl-line-range-function.

Defined variables (14)

global-hl-line-buffersWhether the Global HL-Line mode should be enabled in a buffer.
global-hl-line-modeNon-nil if Global Hl-Line mode is enabled.
global-hl-line-mode-hookHook run after entering or leaving ‘global-hl-line-mode’.
global-hl-line-overlayOverlay used by Global-Hl-Line mode to highlight the current line.
global-hl-line-overlaysOverlays used by Global-Hl-Line mode in various buffers.
global-hl-line-sticky-flagNon-nil means the Global HL-Line mode highlight appears in all windows.
hl-line-faceFace with which to highlight the current line in Hl-Line mode.
hl-line-modeNon-nil if Hl-Line mode is enabled.
hl-line-mode-hookHook run after entering or leaving ‘hl-line-mode’.
hl-line-overlayOverlay used by Hl-Line mode to highlight the current line.
hl-line-overlay-bufferMost recently visited buffer in which Hl-Line mode is enabled.
hl-line-overlay-priorityPriority used on the overlay used by hl-line.
hl-line-range-functionIf non-nil, function to call to return highlight range.
hl-line-sticky-flagNon-nil means the HL-Line mode highlight appears in all windows.

Defined functions (13)

global-hl-line-highlight()
global-hl-line-highlight-all()
global-hl-line-maybe-unhighlight()
global-hl-line-mode(&optional ARG)
global-hl-line-unhighlight()
global-hl-line-unhighlight-all()
global-hl-line-window-redisplay(WINDOW)
hl-line-highlight()
hl-line-maybe-unhighlight()
hl-line-mode(&optional ARG)
hl-line-move(OVERLAY)
hl-line-unhighlight()
hl-line-unload-function()

Defined faces (2)

hl-lineDefault face for highlighting the current line in Hl-Line mode.
hl-line-nonselectedFace for highlighting the line with non-selected window’s point. Used only when the value of ‘global-hl-line-sticky-flag’ is ‘window’.