pair-hl.el is a minor mode that dynamically highlights the enclosing and
adjacent delimiter pairs as you move point. When a pair is off-screen,
it can display the relevant lines in the echo area. Works for
parentheses, brackets, braces and string quotes.
(add-to-list 'load-path "/path/to/pair-hl.el")
(require 'pair-hl)To toggle the mode in the current buffer: M-x pair-hl-mode
To start the mode automatically in most programming modes:
(add-hook 'prog-mode-hook #'pair-hl-mode)| Face | Default | Meaning |
|---|---|---|
pair-hl-enclosing-face | underline | Inner enclosing pair |
pair-hl-adjacent-before-face | wheat background | Pair directly before pt |
pair-hl-adjacent-after-face | turquoise bg | Pair directly after pt |
pair-hl-mismatch-face | salmon background | Unmatched/mismatched |
| Option | Default | Description |
|---|---|---|
pair-hl-debounce-delay | 0.2 | Idle seconds before recalc (0 = immediate) |
pair-hl-highlight-enclosing | t | Highlight innermost enclosing pair |
pair-hl-highlight-adjacent-before | t | Highlight pair directly before point |
pair-hl-highlight-adjacent-after | t | Highlight pair directly after point |
pair-hl-adjacent-max-distance | 1 | Max chars to scan around point for adjacent pairs |
pair-hl-highlight-string-quotes | t | Highlight string-quote delimiters (class 7) |
pair-hl-show-pair-context-when-offscreen | adjacent | Show pair line in echo area when off-screen (nil, adjacent, or t) |
When pair-hl-show-pair-context-when-offscreen is non-nil, the mode shows
the line(s) containing off-screen highlighted pairs in the echo area:
nil(Off): Never show off-screen context.adjacent(Adjacent pairs only): Show only adjacent pairs, excluding the enclosing pair.t(All highlighted pairs): Show both enclosing and adjacent pairs.
- Relies on the buffer’s syntax table; delimiter detection depends on the major mode providing correct syntax classes.
- Does not scan inside strings or comments for literal delimiters.
GPL-3.0-or-later