unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* grep options
@ 2011-01-14 18:47 Ken Goldman
  2011-01-15  7:16 ` Thierry Volpiatto
  0 siblings, 1 reply; 13+ messages in thread
From: Ken Goldman @ 2011-01-14 18:47 UTC (permalink / raw)
  To: help-gnu-emacs

When I use grep on C source, I'd like it to search all C source (.c, .h, 
.cpp), not just the files with the same extension.

I could do that with the (obsolete) igrep like this.  Can I reproduce it 
with emacs 23 / grep?

(put 'igrep-files-default 'c-mode
      (lambda () "*.[ch] *.cpp"))





^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: grep options
  2011-01-14 18:47 grep options Ken Goldman
@ 2011-01-15  7:16 ` Thierry Volpiatto
  2011-01-15  7:19   ` Thierry Volpiatto
  2011-01-16 20:32   ` Kenneth Goldman
  0 siblings, 2 replies; 13+ messages in thread
From: Thierry Volpiatto @ 2011-01-15  7:16 UTC (permalink / raw)
  To: help-gnu-emacs

Ken Goldman <kgold@watson.ibm.com> writes:

> When I use grep on C source, I'd like it to search all C source (.c,
> .h, .cpp), not just the files with the same extension.
>
> I could do that with the (obsolete) igrep like this.  Can I reproduce
> it with emacs 23 / grep?
>
> (put 'igrep-files-default 'c-mode
>      (lambda () "*.[ch] *.cpp"))

Anything grep that come with anything-config.el allow you to do that in
two ways:

1) If you want to do a recursive search from your directory, access grep
with C-u, you will be prompted with "OnlyExt: ", add all the ext you
want like:
*.c *.h *.cpp
(separated with space)

2) if you don't want to recurse, from anything-find-files, narrow dow
the list in your directory by adding a space followed by c$\|h$\|cpp$ at
end of prompt e.g
Pattern: /home/you/work/ c$\|h$\|cpp$

then select grep (no prefix arg this time) and start writting your
pattern.

FYI, this grep is incremental, results changes as you write in minibuffer.

NOTE: You DON'T need the file anything-grep.el that is in anything repo,
this work out of the box with the files:

anything.el
anything-config.el
anything-match-plugin.el

Here is the anything repo:
http://repo.or.cz/w/anything-config.git

For more info on anything, use the mailing-list at:
https://groups.google.com/group/emacs-anything?hl=en

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: grep options
  2011-01-15  7:16 ` Thierry Volpiatto
@ 2011-01-15  7:19   ` Thierry Volpiatto
  2011-01-16 20:32   ` Kenneth Goldman
  1 sibling, 0 replies; 13+ messages in thread
From: Thierry Volpiatto @ 2011-01-15  7:19 UTC (permalink / raw)
  To: help-gnu-emacs

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> Ken Goldman <kgold@watson.ibm.com> writes:
>
>> When I use grep on C source, I'd like it to search all C source (.c,
>> .h, .cpp), not just the files with the same extension.
>>
>> I could do that with the (obsolete) igrep like this.  Can I reproduce
>> it with emacs 23 / grep?
>>
>> (put 'igrep-files-default 'c-mode
>>      (lambda () "*.[ch] *.cpp"))
>
> Anything grep that come with anything-config.el allow you to do that in
> two ways:
>
> 1) If you want to do a recursive search from your directory, access grep
> with C-u, you will be prompted with "OnlyExt: ", add all the ext you
> want like:
> *.c *.h *.cpp
> (separated with space)
>
> 2) if you don't want to recurse, from anything-find-files, narrow dow
> the list in your directory by adding a space followed by c$\|h$\|cpp$ at
> end of prompt e.g
> Pattern: /home/you/work/ c$\|h$\|cpp$

Sorry forget to mention you have to mark all with M-m before grepping.

> then select grep (no prefix arg this time) and start writting your
> pattern.
>
> FYI, this grep is incremental, results changes as you write in minibuffer.
>
> NOTE: You DON'T need the file anything-grep.el that is in anything repo,
> this work out of the box with the files:
>
> anything.el
> anything-config.el
> anything-match-plugin.el
>
> Here is the anything repo:
> http://repo.or.cz/w/anything-config.git
>
> For more info on anything, use the mailing-list at:
> https://groups.google.com/group/emacs-anything?hl=en

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: grep options
  2011-01-15  7:16 ` Thierry Volpiatto
  2011-01-15  7:19   ` Thierry Volpiatto
@ 2011-01-16 20:32   ` Kenneth Goldman
  2011-01-21  7:03     ` Kevin Rodgers
  1 sibling, 1 reply; 13+ messages in thread
From: Kenneth Goldman @ 2011-01-16 20:32 UTC (permalink / raw)
  Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 2100 bytes --]

This looks like a lot more work than igrep.  I didn't have to select files 
and manually
enter the extensions.  igrep just knew that, if the file was c-mode, it 
should search
*.[ch] *.cpp --- by default.

In combination for "search for the string under point", I could grep with 
a single keystroke.

help-gnu-emacs-bounces+kgold=watson.ibm.com@gnu.org wrote on 01/15/2011 
02:16:53 AM:

> From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
> To: help-gnu-emacs@gnu.org
> Date: 01/15/2011 02:18 AM
> Subject: Re: grep options
> Sent by: help-gnu-emacs-bounces+kgold=watson.ibm.com@gnu.org
> 
> Ken Goldman <kgold@watson.ibm.com> writes:
> 
> > When I use grep on C source, I'd like it to search all C source (.c,
> > .h, .cpp), not just the files with the same extension.
> >
> > I could do that with the (obsolete) igrep like this.  Can I reproduce
> > it with emacs 23 / grep?
> >
> > (put 'igrep-files-default 'c-mode
> >      (lambda () "*.[ch] *.cpp"))
> 
> Anything grep that come with anything-config.el allow you to do that in
> two ways:
> 
> 1) If you want to do a recursive search from your directory, access grep
> with C-u, you will be prompted with "OnlyExt: ", add all the ext you
> want like:
> *.c *.h *.cpp
> (separated with space)
> 
> 2) if you don't want to recurse, from anything-find-files, narrow dow
> the list in your directory by adding a space followed by c$\|h$\|cpp$ at
> end of prompt e.g
> Pattern: /home/you/work/ c$\|h$\|cpp$
> 
> then select grep (no prefix arg this time) and start writting your
> pattern.
> 
> FYI, this grep is incremental, results changes as you write in 
minibuffer.
> 
> NOTE: You DON'T need the file anything-grep.el that is in anything repo,
> this work out of the box with the files:
> 
> anything.el
> anything-config.el
> anything-match-plugin.el
> 
> Here is the anything repo:
> http://repo.or.cz/w/anything-config.git
> 
> For more info on anything, use the mailing-list at:
> https://groups.google.com/group/emacs-anything?hl=en
> 
> -- 
> A+ Thierry
> Get my Gnupg key:
> gpg --keyserver pgp.mit.edu --recv-keys 59F29997 
> 
> 

[-- Attachment #2: Type: text/html, Size: 3171 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: grep options
  2011-01-16 20:32   ` Kenneth Goldman
@ 2011-01-21  7:03     ` Kevin Rodgers
  2011-01-21 19:33       ` Ken Goldman
  0 siblings, 1 reply; 13+ messages in thread
From: Kevin Rodgers @ 2011-01-21  7:03 UTC (permalink / raw)
  To: help-gnu-emacs

On 1/16/11 1:32 PM, Kenneth Goldman wrote:
> This looks like a lot more work than igrep. I didn't have to select files and
> manually
> enter the extensions. igrep just knew that, if the file was c-mode, it should
> search
> *.[ch] *.cpp --- by default.

Try M-x lgrep instead.  It also comes preconfigured via grep-files-aliases, but
you should be able to push ("ALIAS" . "WILDCARD ...") entries on to the front to
customize it.

> In combination for "search for the string under point", I could grep with a
> single keystroke.

-- 
Kevin Rodgers
Denver, Colorado, USA




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: grep options
  2011-01-21  7:03     ` Kevin Rodgers
@ 2011-01-21 19:33       ` Ken Goldman
  2011-01-21 21:14         ` guivho
                           ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Ken Goldman @ 2011-01-21 19:33 UTC (permalink / raw)
  To: help-gnu-emacs

On 01/21/2011 02:03 AM, Kevin Rodgers wrote:
>
> Try M-x lgrep instead. It also comes preconfigured via
> grep-files-aliases, but
> you should be able to push ("ALIAS" . "WILDCARD ...") entries on to the
> front to
> customize it.

lgrep is OK, but it requires 3 <enter>'s to get anything done.  grep
requires just one <enter>.

	- confirm the search string
	- confirm the file names
	- confirm the directory

Is there a way to tell lgrep to skip the latter two questions?






^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: grep options
  2011-01-21 19:33       ` Ken Goldman
@ 2011-01-21 21:14         ` guivho
  2011-01-22  5:08         ` Leo
       [not found]         ` <mailman.6.1295672954.8460.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 13+ messages in thread
From: guivho @ 2011-01-21 21:14 UTC (permalink / raw)
  To: help-gnu-emacs

> Is there a way to tell lgrep to skip the latter two questions?

C-u C-u lgrep
from the doc string:

With C-u prefix, you can edit the constructed shell command line
before it is executed.
With two C-u prefixes, directly edit and run `grep-command'.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: grep options
  2011-01-21 19:33       ` Ken Goldman
  2011-01-21 21:14         ` guivho
@ 2011-01-22  5:08         ` Leo
  2011-01-24 18:24           ` Ken Goldman
       [not found]         ` <mailman.6.1295672954.8460.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 13+ messages in thread
From: Leo @ 2011-01-22  5:08 UTC (permalink / raw)
  To: Ken Goldman; +Cc: help-gnu-emacs

On 2011-01-22 03:33 +0800, Ken Goldman wrote:
> lgrep is OK, but it requires 3 <enter>'s to get anything done.  grep
> requires just one <enter>.
>
> 	- confirm the search string
> 	- confirm the file names
> 	- confirm the directory
>
> Is there a way to tell lgrep to skip the latter two questions?

That sounds like an awful ui. Do you mind submitting a bug report by M-x
report-emacs-bug so that it may be fixed upstream? thanks.

Leo

-- 
Oracle is the new evil



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: grep options
       [not found]         ` <mailman.6.1295672954.8460.help-gnu-emacs@gnu.org>
@ 2011-01-24  3:58           ` Stefan Monnier
  2011-01-24 18:28             ` Ken Goldman
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2011-01-24  3:58 UTC (permalink / raw)
  To: help-gnu-emacs

> That sounds like an awful ui.  Do you mind submitting a bug report by M-x
> report-emacs-bug so that it may be fixed upstream? thanks.

I don't like that UI either, but I can't understand what you consider as
a bug: that UI is lgrep's raison d'être.
If you don't like it, you can use (C-u?) M-x grep.


        Stefan


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: grep options
  2011-01-22  5:08         ` Leo
@ 2011-01-24 18:24           ` Ken Goldman
  0 siblings, 0 replies; 13+ messages in thread
From: Ken Goldman @ 2011-01-24 18:24 UTC (permalink / raw)
  To: help-gnu-emacs

On 01/22/2011 12:08 AM, Leo wrote:
> On 2011-01-22 03:33 +0800, Ken Goldman wrote:
>> lgrep is OK, but it requires 3<enter>'s to get anything done.  grep
>> requires just one<enter>.
>>
>> 	- confirm the search string
>> 	- confirm the file names
>> 	- confirm the directory
>>
>> Is there a way to tell lgrep to skip the latter two questions?
>
> That sounds like an awful ui. Do you mind submitting a bug report by M-x
> report-emacs-bug so that it may be fixed upstream? thanks.

I hesitate to file a bug report because I assume it's not a bug, just me 
missing an option or some customization.

So does anyone know how to make lgrep default to the files in 
grep-files-aliases and default to the current directory without prompting?






^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: grep options
  2011-01-24  3:58           ` Stefan Monnier
@ 2011-01-24 18:28             ` Ken Goldman
  2011-02-01  2:50               ` Kevin Rodgers
       [not found]               ` <mailman.16.1296528605.21328.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 13+ messages in thread
From: Ken Goldman @ 2011-01-24 18:28 UTC (permalink / raw)
  To: help-gnu-emacs

On 01/23/2011 10:58 PM, Stefan Monnier wrote:
>> That sounds like an awful ui.  Do you mind submitting a bug report by M-x
>> report-emacs-bug so that it may be fixed upstream? thanks.
>
> I don't like that UI either, but I can't understand what you consider as
> a bug: that UI is lgrep's raison d'être.
> If you don't like it, you can use (C-u?) M-x grep.

grep seems even worse than lgrep.  At least lgrep fills in the word 
under the point as the search string.

I'm looking for an equivalent to the old igrep - default to the word 
under the point, the files with the same mode, and the current directory 
--- with no prompting.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: grep options
  2011-01-24 18:28             ` Ken Goldman
@ 2011-02-01  2:50               ` Kevin Rodgers
       [not found]               ` <mailman.16.1296528605.21328.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: Kevin Rodgers @ 2011-02-01  2:50 UTC (permalink / raw)
  To: help-gnu-emacs

On 1/24/11 11:28 AM, Ken Goldman wrote:
> On 01/23/2011 10:58 PM, Stefan Monnier wrote:
>>> That sounds like an awful ui. Do you mind submitting a bug report by M-x
>>> report-emacs-bug so that it may be fixed upstream? thanks.
>>
>> I don't like that UI either, but I can't understand what you consider as
>> a bug: that UI is lgrep's raison d'être.
>> If you don't like it, you can use (C-u?) M-x grep.
>
> grep seems even worse than lgrep. At least lgrep fills in the word under the
> point as the search string.
>
> I'm looking for an equivalent to the old igrep - default to the word under the
> point, the files with the same mode, and the current directory --- with no
> prompting.

Hi Ken,

Good to hear from you again!

Perhaps you can do something like this:

(require 'igrep)

(defadvice lgrep (before interactive-igrep first activate)
   "Read REGEXP, FILES, and DIR using `igrep-read-args'."
   (interactive
    (progn
      (grep-compute-defaults)
      (let ((igrep-args (igrep-read-args)))
        ;; convert (PROGRAM REGEX FILES OPTIONS) to (REGEXP FILES DIR CONFIRM):
        (list (nth 1 igrep-args)
	     (mapconcat 'file-name-nondirectory (nth 2 igrep-args) " ")
	     (mapconcat 'file-name-directory (nth 2 igrep-args) " ")
	     nil)))))

-- 
Kevin Rodgers
Denver, Colorado, USA




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: grep options
       [not found]               ` <mailman.16.1296528605.21328.help-gnu-emacs@gnu.org>
@ 2011-02-01 16:52                 ` Stefan Monnier
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2011-02-01 16:52 UTC (permalink / raw)
  To: help-gnu-emacs

>>>> That sounds like an awful ui. Do you mind submitting a bug report by M-x
>>>> report-emacs-bug so that it may be fixed upstream? thanks.
>>> 
>>> I don't like that UI either, but I can't understand what you consider as
>>> a bug: that UI is lgrep's raison d'être.
>>> If you don't like it, you can use (C-u?) M-x grep.
>> 
>> grep seems even worse than lgrep. At least lgrep fills in the word under the
>> point as the search string.

Not if you provide the C-u prefix.


        Stefan


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-02-01 16:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-14 18:47 grep options Ken Goldman
2011-01-15  7:16 ` Thierry Volpiatto
2011-01-15  7:19   ` Thierry Volpiatto
2011-01-16 20:32   ` Kenneth Goldman
2011-01-21  7:03     ` Kevin Rodgers
2011-01-21 19:33       ` Ken Goldman
2011-01-21 21:14         ` guivho
2011-01-22  5:08         ` Leo
2011-01-24 18:24           ` Ken Goldman
     [not found]         ` <mailman.6.1295672954.8460.help-gnu-emacs@gnu.org>
2011-01-24  3:58           ` Stefan Monnier
2011-01-24 18:28             ` Ken Goldman
2011-02-01  2:50               ` Kevin Rodgers
     [not found]               ` <mailman.16.1296528605.21328.help-gnu-emacs@gnu.org>
2011-02-01 16:52                 ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).