Function: projectile--grep-find-specs

projectile--grep-find-specs is a byte-compiled function defined in projectile.el.

Signature

(projectile--grep-find-specs PATTERNS)

Documentation

Split gitignore-style PATTERNS into specs for the find-based grep.

Return a cons of the root-anchored patterns, spelled relative to the project root, and the floating ones, which match at any depth. Trailing slashes are dropped: find sees directory entries without one, and pruning a directory takes its whole subtree with it anyway.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--grep-find-specs (patterns)
  "Split gitignore-style PATTERNS into specs for the `find'-based grep.
Return a cons of the root-anchored patterns, spelled relative to the
project root, and the floating ones, which match at any depth.  Trailing
slashes are dropped: `find' sees directory entries without one, and
pruning a directory takes its whole subtree with it anyway."
  (let (anchored floating)
    (dolist (pattern patterns)
      (let ((body (string-remove-suffix "/" pattern)))
        (cond ((string-empty-p body))
              ((string-prefix-p "**/" body) (push (substring body 3) floating))
              ((string-prefix-p "/" body) (push (substring body 1) anchored))
              ((string-search "/" body) (push body anchored))
              (t (push body floating)))))
    (cons (nreverse anchored) (nreverse floating))))