From: Lennart Borgman <lennart.borgman.073@student.lu.se>
Subject: Re: Why not a grep-find-simple?
Date: Fri, 18 Aug 2006 19:05:31 +0200 [thread overview]
Message-ID: <44E5F35B.5090402@student.lu.se> (raw)
In-Reply-To: <44E5DB9F.6050105@student.lu.se>
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)))))
next prev parent reply other threads:[~2006-08-18 17:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-18 15:24 Why not a grep-find-simple? Lennart Borgman
2006-08-18 17:05 ` Lennart Borgman [this message]
2006-08-19 22:45 ` Kim F. Storm
2006-08-20 1:15 ` Lennart Borgman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44E5F35B.5090402@student.lu.se \
--to=lennart.borgman.073@student.lu.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.