Function: rgrep-default-command

rgrep-default-command is a byte-compiled function defined in grep.el.gz.

Signature

(rgrep-default-command REGEXP FILES DIR)

Documentation

Compute the command for M-x rgrep (rgrep) to use by default.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/grep.el.gz
(defun rgrep-default-command (regexp files dir)
  "Compute the command for \\[rgrep] to use by default."
  (require 'find-dired)      ; for `find-name-arg'
  (grep-expand-template
   grep-find-template
   regexp
   (concat (shell-quote-argument "(")
           " " find-name-arg " "
           (mapconcat
            #'shell-quote-argument
            (split-string files)
            (concat " -o " find-name-arg " "))
           " "
           (shell-quote-argument ")"))
   dir
   (concat
    (and grep-find-ignored-directories
         (concat "-type d "
                 (shell-quote-argument "(")
                 ;; we should use shell-quote-argument here
                 " -path "
                 (mapconcat (lambda (d) (shell-quote-argument (concat "*/" d)))
                            (rgrep-find-ignored-directories dir)
                            " -o -path ")
                 " "
                 (shell-quote-argument ")")
                 " -prune -o "))
    (and grep-find-ignored-files
         (concat (shell-quote-argument "!") " -type d "
                 (shell-quote-argument "(")
                 ;; we should use shell-quote-argument here
                 " -name "
                 (mapconcat
                  (lambda (ignore)
                    (cond ((stringp ignore)
                           (shell-quote-argument ignore))
                          ((consp ignore)
                           (and (funcall (car ignore) dir)
                                (shell-quote-argument
                                 (cdr ignore))))))
                  grep-find-ignored-files
                  " -o -name ")
                 " "
                 (shell-quote-argument ")")
                 " -prune -o ")))))