Function: hi-lock-line-face-buffer

hi-lock-line-face-buffer is an autoloaded, interactive and byte-compiled function defined in hi-lock.el.gz.

Signature

(hi-lock-line-face-buffer REGEXP &optional FACE)

Documentation

Highlight all lines that match REGEXP using FACE.

The lines that match REGEXP will be displayed by merging the attributes of FACE with any other face attributes of text in those lines.

Interactively, prompt for REGEXP using hi-lock-read-regexp, then FACE. Use the global history list for FACE.

If REGEXP contains upper case characters (excluding those preceded by \) and search-upper-case is non-nil, the matching is case-sensitive.

Use Font lock mode, if enabled, to highlight REGEXP. Otherwise, use overlays for highlighting. If overlays are used, the highlighting will not update as you type.

Probably introduced at or before Emacs version 31.1.

Key Bindings

Aliases

highlight-lines-matching-regexp

Source Code

;; Defined in /usr/src/emacs/lisp/hi-lock.el.gz
;;;###autoload
(defun hi-lock-line-face-buffer (regexp &optional face)
  "Highlight all lines that match REGEXP using FACE.
The lines that match REGEXP will be displayed by merging
the attributes of FACE with any other face attributes
of text in those lines.

Interactively, prompt for REGEXP using `hi-lock-read-regexp', then FACE.
Use the global history list for FACE.

If REGEXP contains upper case characters (excluding those preceded by `\\')
and `search-upper-case' is non-nil, the matching is case-sensitive.

Use Font lock mode, if enabled, to highlight REGEXP.  Otherwise,
use overlays for highlighting.  If overlays are used, the
highlighting will not update as you type."
  (interactive
   (list
    (hi-lock-read-regexp "Regexp to highlight line")
    (hi-lock-read-face-name)))
  (or (facep face) (setq face 'hi-yellow))
  (unless hi-lock-mode (hi-lock-mode 1))
  (hi-lock-set-pattern
   ;; The \\(?:...\\) grouping construct ensures that a leading ^, +, * or ?
   ;; or a trailing $ in REGEXP will be interpreted correctly.
   (concat "^.*\\(?:" regexp "\\).*\\(?:$\\)\n?") face nil nil
   (if (and case-fold-search search-upper-case)
       (isearch-no-upper-case-p regexp t)
     case-fold-search)))