Function: projectile-search--rg-command

projectile-search--rg-command is a byte-compiled function defined in projectile.el.

Signature

(projectile-search--rg-command TERM CASE-FOLD WORD GLOBS &optional PATTERN)

Documentation

Build the rg --json command line searching for literal TERM.

When PATTERN is non-nil it is searched for as a ripgrep-syntax regexp instead, and TERM is ignored. CASE-FOLD selects case-insensitive matching; WORD restricts matches to whole words (--word-regexp); GLOBS is a list of ignore patterns (from projectile--project-ignore-globs) passed as --glob exclusions so Projectile's ignores narrow ripgrep's own ignore rules. They are gitignore patterns, which is what ripgrep's globs are, so they need no translation - but a root-anchored one only resolves against the project root when the searched path is relative, which is why the search path below is ./ and the caller must run the process with default-directory bound to the project root.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile-search--rg-command (term case-fold word globs &optional pattern)
  "Build the `rg --json' command line searching for literal TERM.
When PATTERN is non-nil it is searched for as a ripgrep-syntax regexp
instead, and TERM is ignored.  CASE-FOLD selects case-insensitive
matching; WORD restricts matches to whole words (`--word-regexp'); GLOBS
is a list of ignore patterns (from `projectile--project-ignore-globs')
passed as `--glob' exclusions so Projectile's ignores narrow ripgrep's
own ignore rules.  They are gitignore patterns, which is what ripgrep's
globs are, so they need no translation - but a root-anchored one only
resolves against the project root when the searched path is relative,
which is why the search path below is `./' and the caller must run the
process with `default-directory' bound to the project root."
  (append
   (list (projectile-search--rg-executable)
         "--json" "--line-number" "--column"
         "--color" "never"
         (if case-fold "--ignore-case" "--case-sensitive"))
   (unless pattern (list "--fixed-strings"))
   (when word (list "--word-regexp"))
   (mapcan (lambda (g) (list "--glob" (concat "!" g))) globs)
   ;; `--' terminates options so a TERM starting with `-' is not misread.
   (list "--" (or pattern term) "./")))