From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Re: Why not a grep-find-simple? Date: Fri, 18 Aug 2006 19:05:31 +0200 Message-ID: <44E5F35B.5090402@student.lu.se> References: <44E5DB9F.6050105@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1155920758 4278 80.91.229.2 (18 Aug 2006 17:05:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 18 Aug 2006 17:05:58 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 18 19:05:55 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GE7n5-0003kB-Q3 for ged-emacs-devel@m.gmane.org; Fri, 18 Aug 2006 19:05:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GE7n5-0002te-7z for ged-emacs-devel@m.gmane.org; Fri, 18 Aug 2006 13:05:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GE7mv-0002sO-48 for emacs-devel@gnu.org; Fri, 18 Aug 2006 13:05:41 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GE7mt-0002qz-3G for emacs-devel@gnu.org; Fri, 18 Aug 2006 13:05:40 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GE7ms-0002qt-TJ for emacs-devel@gnu.org; Fri, 18 Aug 2006 13:05:38 -0400 Original-Received: from [81.228.8.83] (helo=pne-smtpout1-sn2.hy.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GE7td-00061h-7S for emacs-devel@gnu.org; Fri, 18 Aug 2006 13:12:37 -0400 Original-Received: from [192.168.123.121] (83.249.218.244) by pne-smtpout1-sn2.hy.skanova.net (7.2.075) id 44A2E86F00A6F822 for emacs-devel@gnu.org; Fri, 18 Aug 2006 19:05:37 +0200 User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) Original-To: Emacs Devel In-Reply-To: <44E5DB9F.6050105@student.lu.se> X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:58495 Archived-At: Lennart Borgman wrote: > I think it would be good to have a more easy to use version of > `grep-find' that asks for the most common parameters. I would suggest: > > - Directory > - File name pattern > - Grep pattern No answers yet so I supply a simple version for this: (defvar grep-find-simple-filepatt-history nil) (defvar grep-find-simple-grepregexp-history nil) (defun grep-find-simple(top-dir file-pattern grep-regexp) "Run grep via find, prompt for commonly used parameters. This is a simplified interface to `grep-find'. It prompts for some of the probably most commonly used parameters to that command: TOP-DIR is root directory for search. FILE-PATTERN tells that only file with matching names should be searched. GREP-REGEXP is a grep style regular expression that grep should search for. FILE-PATTERN and GREP-REGEXP has their own history lists." (interactive (list (read-directory-name "Root directory for search: " nil nil t) (read-from-minibuffer "File name pattern: " nil nil nil 'grep-find-simple-filepatt-history) (read-from-minibuffer "Grep regexp: " nil nil nil 'grep-find-simple-grepregexp-history))) (grep-compute-defaults) (if (not (string-match "-type f " grep-find-command)) (error "Can't find '-type f' in grep-find-command") (let* ((begin (match-beginning 0)) (end (match-end 0)) (default-directory (file-name-as-directory top-dir)) (grep-find-command (if (string= "" file-pattern) (concat grep-find-command grep-regexp) (concat (substring grep-find-command 0 begin) "-type f -name '" file-pattern "' " (substring grep-find-command end) grep-regexp)))) (if (string= "" grep-regexp) (message "No grep regexp to search for") (call-interactively 'grep-find)))))