HighlightCurrentLine

This page is about libraries that highlight the current line of characters, so you can find it easily.

Standard Library `hl-line.el'

GnuEmacs version 21 has library `hl-line.el’, which provides a local and a global minor mode for highlighting the current line. See highlight current line.

Extension Library `hl-spotlight.el'

Library hl-spotlight.el extends standard library `hl-line.el’. It spotlights the current few lines using a different face from that used by `hl-line.el’. It is designed to be used together with library centered-cursor-mode.el, so that the lines surrounding the cursor remain highlighted, and these spotlighted lines remain in the center of the window.

`hl-spotlight.el’ separates its spotlighting from your normal use of ‘hl-line’ highlighting. It does this in these ways:

Extension Library `hl-line+.el'

Library hl-line+.el extends standard library `hl-line.el’ in several ways. It provides these commands:

The idea for both of these is to let ‘hl-line-mode’ help you find the current line, but not keep highlighting it after you’ve found it.

In addition, library hl-line+.el provides local and global modes (commands ‘hl-spotlight-mode’ and ‘global-hl-spotlight-mode’) to highlight several lines surrounding the cursor using a different face, ‘hl-spotlight’. You can enlarge or shrink this spotlight highlighting using command ‘hl-spotlight-enlarge’. You can repeat, via `C-x z z z z…’, to enlarge or shrink the spotlight incrementally.

Spotlight highlighting can be used together with library centered-cursor-mode.el, by AndreRiemann, which keeps the cursor (hence also the spotlight) centered in the window. This can be helpful when reading text (as opposed to code). This is controlled by user option ‘hl-spotlight-keep-centered-flag’.

See Also:

Discussion

Question: In ~/.emacs (toggle-hl-line-when-idle 1) now works, but (flash-line-highlight 1) gives “Symbol’s function definition is void: global-hl-line-highlight”. (require 'hl-line) and (global-hl-line-mode 1) both work: so I suppose I’m loading hl-line.el well. I cannot see its content, because it’s an .elc installed by debian emacs21 package (21.4). Thanks a lot… maybe I’ll upgrade. Bye!

You are apparently using Emacs 21, not Emacs 22. As the Compatibility: field in the header of hl-line+.el states, it works with GnuEmacs 22. It is an extension of hl-line.el of Emacs 22, where ‘global-hl-line-highlight’ is defined. You can try to see if hl-line+.el works at all with Emacs 21, but all bets are off. To try that, you’ll need to tweak things a bit, to at least suppress the error message. It is useless to (setq global-hl-line-highlight 1) – it is a function (in Emacs 22), not a variable. Thx – DrewAdams


Question:. I’m using (toggle-hl-line-when-idle 1) in my ~/.emacs. and I don’t want to highlight line when I’m in Info mode or Help mode etc. I try to use (add-hook ‘Info-mode-hook ‘(lambda () (toggle-hl-line-when-idle -1))) but after I trigger this it turn off highlight on other buffers too. Is there a way to turn on/off this mode only for current buffer and how? – Yuanle

Good question. No, I’m sorry, there is no simple way to do that. hl-line+.el uses only global hl-line mode. There is a single idle timer for this, and it has no notion of the current mode.

You might try to change the definition of ‘hl-line-idle-timer’ to run not ‘hl-line-highlight-now’, but some new command ‘hl-line-highlight-local-now’, which is like the global version but uses ‘hl-line-mode’ etc. instead of ‘global-hl-line-mode’ etc. You will need an unhighlight version too, etc.

If you do that and like what you end up with, I could add it to the library, if you like. – DrewAdams

Library `highlight-current-line.el'

There is also Lisp:highlight-current-line.el

Library `highline.el'

At least Gentoo ships a library with this name written and maintained by ViniciusJoseLatorre.

See Lisp:highline.el (HighlineMode).

Library `pulse.el'

See PulseRegion, function ‘pulse-momentary-highlight-one-line’.

XEmacs Compatibility


CategoryEditing CategoryDisplay CategoryAccessibility CategoryFaces HighlightTemporarily