Function: zrgrep

zrgrep is an autoloaded, interactive and byte-compiled function defined in grep.el.gz.

Signature

(zrgrep REGEXP &optional FILES DIR CONFIRM TEMPLATE)

Documentation

Recursively grep for REGEXP in gzipped FILES in tree rooted at DIR.

Like rgrep but uses zgrep for grep-program, sets the default file name to *.gz, and sets grep-highlight-matches to always.

If CONFIRM is non-nil, the user will be given an opportunity to edit the command before it's run.

Probably introduced at or before Emacs version 23.2.

Key Bindings

Aliases

rzgrep

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/grep.el.gz
;;;###autoload
(defun zrgrep (regexp &optional files dir confirm template)
  "Recursively grep for REGEXP in gzipped FILES in tree rooted at DIR.
Like `rgrep' but uses `zgrep' for `grep-program', sets the default
file name to `*.gz', and sets `grep-highlight-matches' to `always'.

If CONFIRM is non-nil, the user will be given an opportunity to edit the
command before it's run."
  (interactive
   (progn
     ;; Compute standard default values.
     (grep-compute-defaults)
     ;; Compute the default zrgrep command by running `grep-compute-defaults'
     ;; for grep program "zgrep", but not changing global values.
     (let ((grep-program "zgrep")
	   ;; Don't change global values for variables computed
	   ;; by `grep-compute-defaults'.
	   (grep-find-template nil)
	   (grep-find-command nil)
	   (grep-host-defaults-alist nil)
           ;; `zgrep' doesn't support the `--null' option.
	   (grep-use-null-filename-separator nil)
	   ;; Use for `grep-read-files'
	   (grep-files-aliases '(("all" . "* .*")
				 ("gz"  . "*.gz"))))
       ;; Recompute defaults using let-bound values above.
       (grep-compute-defaults)
       (cond
	((and grep-find-command (equal current-prefix-arg '(16)))
	 (list (read-from-minibuffer "Run: " grep-find-command
				     nil nil 'grep-find-history)))
	((not grep-find-template)
	 (error "grep.el: No `grep-find-template' available"))
	(t (let* ((regexp (grep-read-regexp))
		  (files (grep-read-files regexp))
		  (dir (read-directory-name "Base directory: "
					    nil default-directory t))
		  (confirm (equal current-prefix-arg '(4))))
	     (list regexp files dir confirm grep-find-template)))))))
  (let ((grep-find-template template)
        ;; Set `grep-highlight-matches' to `always'
        ;; since `zgrep' puts filters in the grep output.
        (grep-highlight-matches 'always))
    (rgrep regexp files dir confirm)))