* doc/emacs/building.texi (Grep Searching): Document it.
* lisp/progmodes/grep.el (grep-match-regexp): New variable (bug#41766).
(grep-filter): Use it.
@xref{Compilation Mode}, for detailed description of commands and key
bindings available in the @file{*grep*} buffer.
+@vindex grep-match-regexp}
Some grep programs accept a @samp{--color} option to output special
markers around matches for the purpose of highlighting. You can make
use of this feature by setting @code{grep-highlight-matches} to
@code{t}. When displaying a match in the source buffer, the exact
match will be highlighted, instead of the entire source line.
+Highlighting is provided via matching the @acronym{ANSI} escape
+sequences emitted by @command{grep}. The matching of the sequences is
+controlled by @code{grep-match-regexp}, which can be customized to
+accommodate different @command{grep} programs.
As with compilation commands (@pxref{Compilation}), while the grep
command runs, the mode line shows the running number of matches found
A server entry retrieved by auth-source can request a desired smtp
authentication mechanism by setting a value for the key 'smtp-auth'.
+** Grep
+
++++
+*** New variable 'grep-match-regexp' matches grep markers to highlight.
+grep emits SGR ANSI escape sequences to color its output. The new variable
+'grep-match-regexp' holds the regular expression to match the appropriate
+markers in order to provide highlighting in the source buffer. The variable
+can be customized to accommodate other grep-like tools.
+
** Help
+++
:set #'grep-apply-setting
:version "22.1")
+(defcustom grep-match-regexp "\033\\[0?1;31m\\(.*?\\)\033\\[[0-9]*m"
+ "Regular expression matching grep markers to highlight.
+It matches SGR ANSI escape sequences which are emitted by grep to
+color its output. This variable is used in `grep-filter'."
+ :type 'regexp
+ :version "28.1")
+
(defcustom grep-scroll-output nil
"Non-nil to scroll the *grep* buffer window as output appears.
(when (< (point) end)
(setq end (copy-marker end))
;; Highlight grep matches and delete marking sequences.
- (while (re-search-forward "\033\\[0?1;31m\\(.*?\\)\033\\[[0-9]*m" end 1)
+ (while (re-search-forward grep-match-regexp end 1)
(replace-match (propertize (match-string 1)
'face nil 'font-lock-face grep-match-face)
t t)