Function: projectile-ripgrep

projectile-ripgrep is an autoloaded, interactive and byte-compiled function defined in projectile.el.

Signature

(projectile-ripgrep SEARCH-TERM &optional ARG)

Documentation

Run a ripgrep (rg) search with SEARCH-TERM at current project root.

With an optional prefix argument ARG SEARCH-TERM is interpreted as a regular expression.

This command depends on the Emacs packages ripgrep or rg being installed to work.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260310.858/projectile.el
;;;###autoload
(defun projectile-ripgrep (search-term &optional arg)
  "Run a ripgrep (rg) search with `SEARCH-TERM' at current project root.

With an optional prefix argument ARG SEARCH-TERM is interpreted as a
regular expression.

This command depends on the Emacs packages ripgrep or rg being
installed to work."
  (interactive
   (list (projectile--read-search-string-with-default
          (format "Ripgrep %ssearch for" (if current-prefix-arg "regexp " "")))
         current-prefix-arg))
  (let ((args (mapcar (lambda (val) (concat "--glob '!" val "'"))
                      (append projectile-globally-ignored-files
                              projectile-globally-ignored-directories))))
    ;; we rely on the external packages ripgrep and rg for the actual search
    ;;
    ;; first we check if we can load ripgrep
    (cond ((require 'ripgrep nil 'noerror)
           (ripgrep-regexp search-term
                           (projectile-acquire-root)
                           (if arg
                               args
                             (cons "--fixed-strings --hidden" args))))
          ;; and then we try rg
          ((require 'rg nil 'noerror)
           (rg-run search-term
                   "*"                       ;; all files
                   (projectile-acquire-root)
                   (not arg)                 ;; literal search?
                   nil                       ;; no need to confirm
                   args))
          (t (error "Packages `ripgrep' and `rg' are not available")))))