Variable: xref-search-program-alist

xref-search-program-alist is a customizable variable defined in xref.el.gz.

Value

((grep . "xargs -0 grep <C> --null -snHE -e <R>")
 (ripgrep
  . "xargs -0 rg <C> --null -nH --no-heading --no-messages -g '!*/' -e <R>")
 (ugrep . "xargs -0 ugrep <C> --null -ns -e <R>"))

Documentation

Association list mapping program identifiers to command templates.

Program identifier should be a symbol, named after the search program.

The command template must be a shell command (or usually a pipeline) that will search the files based on the list of file names that is piped from stdin, separated by null characters. The template should have the following fields:

  <C> for extra arguments such as -i and --color
  <R> for the regexp itself (in Extended format)

This variable was added, or its default value changed, in xref version
1.0.4.

Probably introduced at or before Emacs version 28.1.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/xref.el.gz
;; TODO: Experiment with 'xargs -P4' (or any other number).
;; This speeds up either command, even more than rg's '-j4' does.
;; Ripgrep gets jumbled output, though, even with --line-buffered.
;; But Grep seems to be stable. Even without --line-buffered.
(defcustom xref-search-program-alist
  (let ((xargs-max-chars
         (and (memq system-type '(windows-nt ms-dos))
              "-s 10000 ")))
    `((grep
       .
       ;; '-s' because 'git ls-files' can output broken symlinks.
       ,(concat "xargs -0 " xargs-max-chars "grep <C> --null -snHE -e <R>"))
      (ripgrep
       .
       ;; '!*/' is there to filter out dirs (e.g. submodules).
       ,(concat "xargs -0 "
                xargs-max-chars
                "rg <C> --null -nH --no-heading --no-messages -g '!*/' -e <R>"))
      (ugrep
       .
       ,(concat "xargs -0 " xargs-max-chars "ugrep <C> --null -ns -e <R>"))))
  "Association list mapping program identifiers to command templates.

Program identifier should be a symbol, named after the search program.

The command template must be a shell command (or usually a
pipeline) that will search the files based on the list of file
names that is piped from stdin, separated by null characters.
The template should have the following fields:

  <C> for extra arguments such as -i and --color
  <R> for the regexp itself (in Extended format)"
  :type '(repeat
          (cons (symbol :tag "Program identifier")
                (string :tag "Command template")))
  :version "29.1"
  :package-version '(xref . "1.0.4"))