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'
(let ((ignored-files-arg
(when-let* ((ignored-files (grep-find-ignored-files dir)))
(concat (shell-quote-argument "(" grep-quoting-style)
;; we should use shell-quote-argument here
" -name "
(mapconcat
(lambda (ignore) (shell-quote-argument ignore grep-quoting-style))
ignored-files
" -o -name ")
" " (shell-quote-argument ")" grep-quoting-style)))))
(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)
(when (and rgrep-find-ignores-in-<f> ignored-files-arg)
(concat " " (shell-quote-argument "!" grep-quoting-style) " " ignored-files-arg)))
dir
(concat
(when-let* ((ignored-dirs (rgrep-find-ignored-directories dir)))
(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))
ignored-dirs
" -o -path ")
" "
(shell-quote-argument ")" grep-quoting-style)
" -prune -o "))
(when (and (not rgrep-find-ignores-in-<f>) ignored-files-arg)
(concat (shell-quote-argument "!" grep-quoting-style) " -type d "
ignored-files-arg
" -prune -o "))))))