Function: xref--find-ignores-arguments

xref--find-ignores-arguments is a byte-compiled function defined in xref.el.gz.

Signature

(xref--find-ignores-arguments IGNORES DIR)

Documentation

Convert IGNORES and DIR to a list of arguments for 'find'.

IGNORES is a list of glob patterns. DIR is an absolute directory, used as the root of the ignore globs.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/xref.el.gz
(defun xref--find-ignores-arguments (ignores dir)
  "Convert IGNORES and DIR to a list of arguments for 'find'.
IGNORES is a list of glob patterns.  DIR is an absolute
directory, used as the root of the ignore globs."
  (cl-assert (not (string-match-p "\\`~" dir)))
  (if (not ignores)
      ""
    ;; TODO: All in-tree callers are passing in just "." or "./".
    ;; We can simplify.
    ;; And, if we ever end up deleting xref-matches-in-directory, move
    ;; this function to the project package.
    (setq dir (file-name-as-directory dir))
    (concat
     (shell-quote-argument "(")
     " -path "
     (mapconcat
      (lambda (ignore)
        (when (string-match-p "/\\'" ignore)
          (setq ignore (concat ignore "*")))
        (shell-quote-argument (if (string-match "\\`\\./" ignore)
                                  (replace-match dir t t ignore)
                                (if (string-prefix-p "*" ignore)
                                    ignore
                                  (concat "*/" ignore)))))
      ignores
      " -o -path ")
     " "
     (shell-quote-argument ")")
     " -prune -o ")))