Variable: grep-highlight-matches

grep-highlight-matches is a customizable variable defined in grep.el.gz.

Value

auto-detect

Documentation

Use special markers to highlight grep matches.

Some grep programs are able to surround matches with special markers in grep output. Such markers can be used to highlight matches in grep mode. This requires font-lock-mode(var)/font-lock-mode(fun) to be active in grep buffers, so if you have globally disabled font-lock-mode(var)/font-lock-mode(fun), you will not get highlighting.

This option sets the environment variable GREP_COLORS to specify markers for highlighting and adds the --color option in front of any explicit grep options before starting the grep.

When this option is auto, grep uses --color=auto to highlight matches only when it outputs to a terminal (when grep is the last command in the pipe), thus avoiding the use of any potentially-harmful escape sequences when standard output goes to a file or pipe.

To make grep highlight matches even into a pipe, you need the option always that forces grep to use --color=always to unconditionally output escape sequences.

If the value is auto-detect (the default), grep will call grep-compute-defaults to compute the value. To change the default value, use M-x customize (customize) or call the function grep-apply-setting.

This variable was added, or its default value changed, in Emacs 22.1.

Probably introduced at or before Emacs version 22.1.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/grep.el.gz
;;;###autoload
(defcustom grep-highlight-matches 'auto-detect
  "Use special markers to highlight grep matches.

Some grep programs are able to surround matches with special
markers in grep output.  Such markers can be used to highlight
matches in grep mode.  This requires `font-lock-mode' to be active
in grep buffers, so if you have globally disabled `font-lock-mode',
you will not get highlighting.

This option sets the environment variable GREP_COLORS to specify
markers for highlighting and adds the --color option in front of
any explicit grep options before starting the grep.

When this option is `auto', grep uses `--color=auto' to highlight
matches only when it outputs to a terminal (when `grep' is the last
command in the pipe), thus avoiding the use of any potentially-harmful
escape sequences when standard output goes to a file or pipe.

To make grep highlight matches even into a pipe, you need the option
`always' that forces grep to use `--color=always' to unconditionally
output escape sequences.

If the value is `auto-detect' (the default), `grep' will call
`grep-compute-defaults' to compute the value.  To change the
default value, use \\[customize] or call the function
`grep-apply-setting'."
  :type '(choice (const :tag "Do not highlight matches with grep markers" nil)
		 (const :tag "Highlight matches with grep markers" t)
		 (const :tag "Use --color=always" always)
		 (const :tag "Use --color=auto" auto)
		 (other :tag "Not Set" auto-detect))
  :set #'grep-apply-setting
  :version "22.1")