Function: consult--find-make-builder

consult--find-make-builder is a byte-compiled function defined in consult.el.

Signature

(consult--find-make-builder PATHS)

Documentation

Build find command line, finding across PATHS.

Source Code

;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult.el
(defun consult--find-make-builder (paths)
  "Build find command line, finding across PATHS."
  (let* ((cmd (seq-mapcat (lambda (x)
                            (if (equal x ".") paths (list x)))
                          (consult--build-args consult-find-args)))
         (type (if (eq 0 (process-file-shell-command
                          (concat (car cmd) " -regextype emacs -version")))
                   'emacs 'basic)))
    (lambda (input)
      (pcase-let* ((`(,arg . ,opts) (consult--command-split input))
                   (method (or (seq-find (lambda (o)
                                           (member o '("-name" "-path" "-regex"
                                                       "-iname" "-ipath" "-iregex")))
                                         opts)
                               "-iregex"))
                   (opts (remove method opts))
                   (ignore-case (string-prefix-p "-i" method)))
        (if (not (string-suffix-p "regex" method))
            (when-let* ((args (consult--split-escaped arg)))
              (cons (append cmd
                            (cdr (mapcan
                                  (lambda (x) `("-and" ,method ,(format "*%s*" x)))
                                  args))
                            opts)
                    (apply-partially #'consult--highlight-literals args ignore-case)))
          (pcase-let ((`(,re . ,hl) (consult--compile-regexp arg type ignore-case)))
            (when (or re opts) ;; Either option or regexp must be provided
              (cons (append cmd
                            (cdr (mapcan
                                  (lambda (x)
                                    `("-and" ,method
                                      ,(format
                                        ".*%s.*"
                                        ;; Replace non-capturing groups with capturing groups.
                                        ;; GNU find does not support non-capturing groups.
                                        (replace-regexp-in-string
                                         "\\\\(\\?:" "\\(" x 'fixedcase 'literal))))
                                  re))
                            opts)
                    hl))))))))