Function: projectile-find-references

projectile-find-references is an interactive and byte-compiled function defined in projectile.el.

Signature

(projectile-find-references &optional SYMBOL)

Documentation

Find textual references to SYMBOL across the current project.

SYMBOL defaults to the active region or the symbol at point. The search is scoped to the project root and honours Projectile's ignore configuration (.projectile and the globally-ignored files and directories), like Projectile's other search commands.

This is a backend-agnostic textual search (it greps the project for SYMBOL). For semantic references from a language server or tags table, use the built-in xref-find-references, which is scoped to the Projectile project too when projectile-mode(var)/projectile-mode(fun) is enabled.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile-find-references (&optional symbol)
  "Find textual references to SYMBOL across the current project.

SYMBOL defaults to the active region or the symbol at point.  The search
is scoped to the project root and honours Projectile's ignore
configuration (`.projectile' and the globally-ignored files and
directories), like Projectile's other search commands.

This is a backend-agnostic textual search (it greps the project for
SYMBOL).  For semantic references from a language server or tags table,
use the built-in `xref-find-references', which is scoped to the
Projectile project too when `projectile-mode' is enabled."
  (interactive)
  (require 'xref)
  (let* ((project-root (projectile-acquire-root))
         (symbol (or symbol
                     (read-string
                      (projectile-prepend-project-name "Find references to: ")
                      (projectile-symbol-or-selection-at-point))))
         ;; `xref-matches-in-directory' reads its IGNORES in project.el's
         ;; format, not gitignore's.
         (ignores (mapcar #'projectile--project-el-ignore-glob
                          (projectile--project-ignore-globs project-root)))
         ;; `xref-matches-in-directory' greps for the pattern (honouring
         ;; IGNORES) and re-matches it in-buffer to pin down columns, so a
         ;; plain quoted symbol is the portable choice: symbol/word-boundary
         ;; constructs (`\\_<', `\\b') don't survive the translation to the
         ;; platform grep.
         (regexp (regexp-quote symbol))
         (fetcher (lambda ()
                    (xref-matches-in-directory regexp "*" project-root ignores))))
    (xref-show-xrefs fetcher nil)))