Function: projectile--construct-files-with-string-command

projectile--construct-files-with-string-command is a byte-compiled function defined in projectile.el.

Signature

(projectile--construct-files-with-string-command TOOL SEARCH-TERM &optional FILE-EXT)

Documentation

Build TOOL's files-with-string command for SEARCH-TERM.

The base command comes from projectile-files-with-string-commands and, when FILE-EXT is a string, the extension filter described by projectile--search-tool-descriptors is layered on top.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--construct-files-with-string-command (tool search-term &optional file-ext)
  "Build TOOL's files-with-string command for SEARCH-TERM.
The base command comes from `projectile-files-with-string-commands'
and, when FILE-EXT is a string, the extension filter described by
`projectile--search-tool-descriptors' is layered on top."
  (let* ((base (alist-get tool projectile-files-with-string-commands))
         (desc (alist-get tool projectile--search-tool-descriptors))
         (term-format (plist-get desc :term-format))
         ;; the plain, no-extension command, shared by every :kind
         (core (if term-format (format base search-term)
                 (concat base search-term))))
    (if (not (stringp file-ext))
        core
      (let ((ext (if (plist-get desc :ext-regexp)
                     (projectile--search-glob-to-regexp file-ext)
                   file-ext))
            (open (plist-get desc :ext-open))
            (close (plist-get desc :ext-close)))
        (pcase (plist-get desc :kind)
          ('prefix (concat base open ext close search-term))
          ('suffix (concat core open ext close))
          ('pipe (concat "ack -g '" ext "$' | " base "-x " search-term)))))))