読者です 読者をやめる 読者になる 読者になる

拡張子を指定してfind-grep-dired

emacs

オリジナルのfind-grep-diredでは拡張子を指定して実行できないので, lgrepからソースを借りてそれを実現してみた.

(defun my-find-grep-dired (dir regexp files)
    (interactive
     (let* ((regexp (grep-read-regexp))
            (files (grep-read-files regexp))
            (dir (read-directory-name
                  "In directory: " nil default-directory t)))
       (list dir regexp files)))
    (find-dired dir (concat
                     " -type f "
                     (shell-quote-argument "(")
                     " -iname "
                     (shell-quote-argument files)
                     " "
                     (shell-quote-argument ")")
                     " -exec "
                     grep-program " " find-grep-options " -e "
                     (shell-quote-argument regexp)
                     " /dev/null "
                     (shell-quote-argument "{}")
                     " "
                     (shell-quote-argument ";"))))