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 "(" grep-quoting-style)
           " " find-name-arg " "
           (mapconcat
            (lambda (x) (shell-quote-argument x grep-quoting-style))
            (split-string files)
            (concat " -o " find-name-arg " "))
           " "
           (shell-quote-argument ")" grep-quoting-style))
   dir
   (concat
    (and grep-find-ignored-directories
         (concat "-type d "
                 (shell-quote-argument "(" grep-quoting-style)
                 ;; we should use shell-quote-argument here
                 " -path "
                 (mapconcat
                  (lambda (d)
                    (shell-quote-argument (concat "*/" d) grep-quoting-style))
                  (rgrep-find-ignored-directories dir)
                  " -o -path ")
                 " "
                 (shell-quote-argument ")" grep-quoting-style)
                 " -prune -o "))
    (and grep-find-ignored-files
         (concat (shell-quote-argument "!" grep-quoting-style) " -type d "
                 (shell-quote-argument "(" grep-quoting-style)
                 ;; we should use shell-quote-argument here
                 " -name "
                 (mapconcat
                  (lambda (ignore)
                    (cond ((stringp ignore)
                           (shell-quote-argument ignore grep-quoting-style))
                          ((consp ignore)
                           (and (funcall (car ignore) dir)
                                (shell-quote-argument
                                 (cdr ignore) grep-quoting-style)))))
                  grep-find-ignored-files
                  " -o -name ")
                 " "
                 (shell-quote-argument ")" grep-quoting-style)
                 " -prune -o ")))))