all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Nested grep
@ 2006-11-14 13:35 spamfilteraccount
  2006-11-14 14:55 ` Robert Thorpe
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: spamfilteraccount @ 2006-11-14 13:35 UTC (permalink / raw)


When grepping for something I often follow a certain match and do
another grep to find out more about it. The problem is this eliminates
the original grep buffer (with matches, current state, etc.), so I have
to redo that grep (and start from the first match again if I use
next-error) to continue investigating other matches.

I'd like a nested grep feature for starting an other grep with the
ability to return easily to the previous grep results after I'm
finished with the current one.

Is there an existing package which does something like that?

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

* Re: Nested grep
  2006-11-14 13:35 Nested grep spamfilteraccount
@ 2006-11-14 14:55 ` Robert Thorpe
  2006-11-14 15:02 ` Drew Adams
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Robert Thorpe @ 2006-11-14 14:55 UTC (permalink / raw)


spamfilteraccount@gmail.com wrote:
> When grepping for something I often follow a certain match and do
> another grep to find out more about it. The problem is this eliminates
> the original grep buffer (with matches, current state, etc.), so I have
> to redo that grep (and start from the first match again if I use
> next-error) to continue investigating other matches.
>
> I'd like a nested grep feature for starting an other grep with the
> ability to return easily to the previous grep results after I'm
> finished with the current one.
>
> Is there an existing package which does something like that?

You can...

Use a double grep at the start, ie when it says:
Run grep like this: grep -n -e
Change it to include two greps and a pipe.

Or, better once the grep buffer is open use M-x occur on that buffer.
See C-h f occur.

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

* RE: Nested grep
  2006-11-14 13:35 Nested grep spamfilteraccount
  2006-11-14 14:55 ` Robert Thorpe
@ 2006-11-14 15:02 ` Drew Adams
       [not found] ` <mailman.569.1163516549.2155.help-gnu-emacs@gnu.org>
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Drew Adams @ 2006-11-14 15:02 UTC (permalink / raw)


> When grepping for something I often follow a certain match and do
> another grep to find out more about it. The problem is this eliminates
> the original grep buffer (with matches, current state, etc.), so I have
> to redo that grep (and start from the first match again if I use
> next-error) to continue investigating other matches.
>
> I'd like a nested grep feature for starting an other grep with the
> ability to return easily to the previous grep results after I'm
> finished with the current one.
>
> Is there an existing package which does something like that?

In Emacs 22 you can pipe the output of one grep to another: grep foo|grep
bar|grep toto. Just type that at the grep prompt.

You might also be interested in Icicles command `icicle-compilation-search'
(`C-c `' in buffer *grep*), which lets you search among grep hits using
additional regexps -
http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Other_Search_Commands.

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

* Re: Nested grep
       [not found] ` <mailman.569.1163516549.2155.help-gnu-emacs@gnu.org>
@ 2006-11-14 16:00   ` spamfilteraccount
  0 siblings, 0 replies; 20+ messages in thread
From: spamfilteraccount @ 2006-11-14 16:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 636 bytes --]


Drew Adams írta:
>
> In Emacs 22 you can pipe the output of one grep to another: grep foo|grep
> bar|grep toto. Just type that at the grep prompt.
>
> You might also be interested in Icicles command `icicle-compilation-search'
> (`C-c `' in buffer *grep*), which lets you search among grep hits using
> additional regexps -
> http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Other_Search_Commands.

Thanks, but none of these are what I need.

I don't want to combine two grep commands. I want to run two completely
different ones  with the ability to restore the results of the first
after I'm finished with the second.

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

* Re: Nested grep
  2006-11-14 13:35 Nested grep spamfilteraccount
                   ` (2 preceding siblings ...)
       [not found] ` <mailman.569.1163516549.2155.help-gnu-emacs@gnu.org>
@ 2006-11-14 16:11 ` Markus Triska
  2006-11-14 16:34   ` spamfilteraccount
  2006-11-14 18:21 ` Peter Dyballa
  4 siblings, 1 reply; 20+ messages in thread
From: Markus Triska @ 2006-11-14 16:11 UTC (permalink / raw)


"spamfilteraccount@gmail.com" <spamfilteraccount@gmail.com> writes:

> I'd like a nested grep feature for starting an other grep with the
> ability to return easily to the previous grep results after I'm
> finished with the current one.

M-x rename-buffer and M-x rename-uniquely in "*grep*" buffer allow you
to rename it, and subsequent greps will create a new one.

All the best! -- Markus Triska

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

* Re: Nested grep
  2006-11-14 16:11 ` Markus Triska
@ 2006-11-14 16:34   ` spamfilteraccount
  2006-11-14 16:40     ` Markus Triska
  0 siblings, 1 reply; 20+ messages in thread
From: spamfilteraccount @ 2006-11-14 16:34 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 579 bytes --]


Markus Triska írta:
> "spamfilteraccount@gmail.com" <spamfilteraccount@gmail.com> writes:
>
> > I'd like a nested grep feature for starting an other grep with the
> > ability to return easily to the previous grep results after I'm
> > finished with the current one.
>
> M-x rename-buffer and M-x rename-uniquely in "*grep*" buffer allow you
> to rename it, and subsequent greps will create a new one.

Will I also be able to use next-error on the results of the first grep
from the match I left off after I'm done with the second grep?

Because that's the point.

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

* Re: Nested grep
  2006-11-14 16:34   ` spamfilteraccount
@ 2006-11-14 16:40     ` Markus Triska
  2006-11-14 17:00       ` spamfilteraccount
  0 siblings, 1 reply; 20+ messages in thread
From: Markus Triska @ 2006-11-14 16:40 UTC (permalink / raw)


"spamfilteraccount@gmail.com" <spamfilteraccount@gmail.com> writes:

> Will I also be able to use next-error on the results of the first grep
> from the match I left off after I'm done with the second grep?

Yes.

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

* Re: Nested grep
  2006-11-14 16:40     ` Markus Triska
@ 2006-11-14 17:00       ` spamfilteraccount
  2006-11-14 17:32         ` spamfilteraccount
  0 siblings, 1 reply; 20+ messages in thread
From: spamfilteraccount @ 2006-11-14 17:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 300 bytes --]


Markus Triska írta:
> "spamfilteraccount@gmail.com" <spamfilteraccount@gmail.com> writes:
>
> > Will I also be able to use next-error on the results of the first grep
> > from the match I left off after I'm done with the second grep?
> 
> Yes.

It really does work. Awesome! :)

Thanks.

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

* Re: Nested grep
  2006-11-14 17:00       ` spamfilteraccount
@ 2006-11-14 17:32         ` spamfilteraccount
  2006-11-14 21:54           ` Drew Adams
       [not found]           ` <mailman.604.1163541320.2155.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 20+ messages in thread
From: spamfilteraccount @ 2006-11-14 17:32 UTC (permalink / raw)



spamfilteraccount@gmail.com írta:
> Markus Triska írta:
> > "spamfilteraccount@gmail.com" <spamfilteraccount@gmail.com> writes:
> >
> > > Will I also be able to use next-error on the results of the first grep
> > > from the match I left off after I'm done with the second grep?
> >
> > Yes.
>
> It really does work. Awesome! :)
>

I quickly made some convenience bindings for the grep buffer to support
this. Hey, Drew! Don't you want to add something like this to
grep-plus? It would be a good fit.


(require 'compile)
(require 'cl)

(defvar my-grep-stack nil)

(define-key compilation-minor-mode-map "s" 'my-grep-stack-buffer-push)
(define-key compilation-minor-mode-map "q" 'my-grep-stack-buffer-pop)

(defun my-grep-stack-buffer-push ()
  (interactive)
  (push (current-buffer) my-grep-stack)
  (rename-uniquely)
  (message "Grep buffer pushed to stack."))


(defun my-grep-stack-buffer-pop ()
  (interactive)
  (quit-window)
  (if my-grep-stack
      (let ((buffer (pop my-grep-stack)))
        (switch-to-buffer buffer)
        (message "Grep buffer popped from stack."))))

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

* Re: Nested grep
  2006-11-14 13:35 Nested grep spamfilteraccount
                   ` (3 preceding siblings ...)
  2006-11-14 16:11 ` Markus Triska
@ 2006-11-14 18:21 ` Peter Dyballa
  4 siblings, 0 replies; 20+ messages in thread
From: Peter Dyballa @ 2006-11-14 18:21 UTC (permalink / raw)
  Cc: help-gnu-emacs


Am 14.11.2006 um 14:35 schrieb spamfilteraccount@gmail.com:

> I'd like a nested grep feature for starting an other grep with the
> ability to return easily to the previous grep results after I'm
> finished with the current one.

With shell-command-on-region you can filter from the *grep* buffer ...

--
Greetings

   Pete

A child of five could understand this!  Fetch me a child of five.

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

* RE: Nested grep
  2006-11-14 17:32         ` spamfilteraccount
@ 2006-11-14 21:54           ` Drew Adams
       [not found]           ` <mailman.604.1163541320.2155.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 20+ messages in thread
From: Drew Adams @ 2006-11-14 21:54 UTC (permalink / raw)


> I quickly made some convenience bindings for the grep buffer to
> support this.
>
> Hey, Drew! Don't you want to add something like this to
> grep-plus? It would be a good fit.

Hi Tamas; thx for the suggestion. FYI - I added some different commands,
which I think might be more useful (YMMV) -
http://www.emacswiki.org/cgi-bin/wiki/grep%2b.el.

New, in grep mode:

`+' - create a new grep buffer (`new-grep-buffer')
`b' - choose (switch to) another grep buffer, with completion
(`choose-grep-buffer')

As before, in grep mode:
`g' - run `grep'
`n' - `next-error-no-select'
`p' - `previous-error-no-select'

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

* Re: Nested grep
       [not found]           ` <mailman.604.1163541320.2155.help-gnu-emacs@gnu.org>
@ 2006-11-15  6:35             ` spamfilteraccount
  2006-11-15 16:36               ` Drew Adams
       [not found]               ` <mailman.653.1163608715.2155.help-gnu-emacs@gnu.org>
  2006-11-15 17:57             ` Peter Lee
  1 sibling, 2 replies; 20+ messages in thread
From: spamfilteraccount @ 2006-11-15  6:35 UTC (permalink / raw)



Drew Adams wrote:
>
> Hi Tamas; thx for the suggestion. FYI - I added some different commands,
> which I think might be more useful (YMMV) -
> http://www.emacswiki.org/cgi-bin/wiki/grep%2b.el.
>

Thanks, I'll try it when the emacs 21 version comes out. I hope you
still support it. :)

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

* RE: Nested grep
  2006-11-15  6:35             ` spamfilteraccount
@ 2006-11-15 16:36               ` Drew Adams
       [not found]               ` <mailman.653.1163608715.2155.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 20+ messages in thread
From: Drew Adams @ 2006-11-15 16:36 UTC (permalink / raw)


> > Hi Tamas; thx for the suggestion. FYI - I added some different commands,
> > which I think might be more useful (YMMV) -
> > http://www.emacswiki.org/cgi-bin/wiki/grep%2b.el.
> >
>
> Thanks, I'll try it when the emacs 21 version comes out. I hope you
> still support it. :)

Not sure what you mean

grep+.el is only for Emacs 22. Prior to Emacs 22, grep was handled in
standard library compile.el, not grep.el.

For Emacs prior to 22, you have compile-20.el and compile+20.el. For Emacs
22 you have grep+.el, compile-.el, and compile+.el.

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

* Re: Nested grep
       [not found]               ` <mailman.653.1163608715.2155.help-gnu-emacs@gnu.org>
@ 2006-11-15 16:47                 ` spamfilteraccount
  2006-11-15 19:02                   ` Drew Adams
       [not found]                   ` <mailman.666.1163617488.2155.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 20+ messages in thread
From: spamfilteraccount @ 2006-11-15 16:47 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 828 bytes --]


Drew Adams írta:
> >
> > Thanks, I'll try it when the emacs 21 version comes out. I hope you
> > still support it. :)
>
> Not sure what you mean
>
> grep+.el is only for Emacs 22. Prior to Emacs 22, grep was handled in
> standard library compile.el, not grep.el.
>
> For Emacs prior to 22, you have compile-20.el and compile+20.el. For Emacs
> 22 you have grep+.el, compile-.el, and compile+.el.

I was under the impression that the packages you describe on the

  http://www.emacswiki.org/cgi-bin/emacs/GrepPlus

page implement the GrepPlus functionality for emacs21 and earlier, and
also for emacs22.

You made this modification in grep+.el which is for emacs 22. I thought
you would add the same functionality to compile-20.el or compile+20.el,
so that these enhancements can be used on emacs21 too.

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

* Re: Nested grep
       [not found]           ` <mailman.604.1163541320.2155.help-gnu-emacs@gnu.org>
  2006-11-15  6:35             ` spamfilteraccount
@ 2006-11-15 17:57             ` Peter Lee
  2006-11-17 16:09               ` Drew Adams
  1 sibling, 1 reply; 20+ messages in thread
From: Peter Lee @ 2006-11-15 17:57 UTC (permalink / raw)


>>>> Drew Adams writes:

    > Hi Tamas; thx for the suggestion. FYI - I added some different commands,
    > which I think might be more useful (YMMV) -
    > http://www.emacswiki.org/cgi-bin/wiki/grep%2b.el.

Drew, I like this package, but have one problem with it.

given the following grep buffer:


-*- mode: grep; default-directory: "/usr/lib/python2.3/site-packages/foo/bar/" -*-
Grep started at Wed Nov 15 11:53:21

find . -type f ! -regex ".*~" ! -regex ".*\.#.*" ! -iname "*.pyc" ! -iname "tags" -print0 | xargs -0 -e grep -nH -i -e _widget
./barconfig.py:291:        self._widget = True
./barconfig.py:308:        return self._widget
./barconfig.py:364:        return bool(self._zzz and self._widget)
./baz.py:645:    def _widget(self, wi):
./baz.py:669:            wi._issue('widget',
./baz.py:672:            wi._issue('widget',
./baz.py:1070:        self._widget(wi)

Grep finished (matches found) at Wed Nov 15 11:53:21


hitting 'n' causes it to hit each line twice.  In other words... I have to hit
'n' twice to advance one error.  However 'p' does not do this, so I'm assuming
it's a bug.

when I hit 'n' the first time it puts cursor here:
./barconfig.py:291:        self._widget = True
^

when I select 'n' again:
./barconfig.py:291:        self._widget = True
                   ^

and next 'n' finally advances.
./barconfig.py:308:        return self._widget
^

and so on...

./barconfig.py:308:        return self._widget
                   ^
Know what this might be?

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

* RE: Nested grep
  2006-11-15 16:47                 ` spamfilteraccount
@ 2006-11-15 19:02                   ` Drew Adams
       [not found]                   ` <mailman.666.1163617488.2155.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 20+ messages in thread
From: Drew Adams @ 2006-11-15 19:02 UTC (permalink / raw)


> > > Thanks, I'll try it when the emacs 21 version comes out. I hope you
> > > still support it. :)
> >
> > Not sure what you mean
> >
> > grep+.el is only for Emacs 22. Prior to Emacs 22, grep was handled in
> > standard library compile.el, not grep.el.
> >
> > For Emacs prior to 22, you have compile-20.el and
> compile+20.el. For Emacs
> > 22 you have grep+.el, compile-.el, and compile+.el.
>
> I was under the impression that the packages you describe on the
>
>   http://www.emacswiki.org/cgi-bin/emacs/GrepPlus
>
> page implement the GrepPlus functionality for emacs21 and earlier, and
> also for emacs22.

Yes, that page describes all of the grep enhancements, for different Emacs
versions - the specifics are mentioned there.

> You made this modification in grep+.el which is for emacs 22. I thought
> you would add the same functionality to compile-20.el or compile+20.el,
> so that these enhancements can be used on emacs21 too.

OK. I just added similar commands to compile+20.el, for use with Emacs
versions prior to 22: http://www.emacswiki.org/cgi-bin/wiki/compile%2b20.el.
However, since there is no grep-specific keymap prior to Emacs 22, I have
not bound the new commands.

HTH - Drew

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

* Re: Nested grep
       [not found]                   ` <mailman.666.1163617488.2155.help-gnu-emacs@gnu.org>
@ 2006-11-16  8:02                     ` spamfilteraccount
  2006-11-16 17:35                       ` Drew Adams
  0 siblings, 1 reply; 20+ messages in thread
From: spamfilteraccount @ 2006-11-16  8:02 UTC (permalink / raw)



Drew Adams wrote:
>
> OK. I just added similar commands to compile+20.el, for use with Emacs
> versions prior to 22: http://www.emacswiki.org/cgi-bin/wiki/compile%2b20.el.
> However, since there is no grep-specific keymap prior to Emacs 22, I have
> not bound the new commands.
>

Thanks, it's working well.  Though I'm missing something like I
originally suggested: an easy way to go back to the previous grep
buffer.

I think when one opens a new grep buffer (while keeping the previous
one) then one usually does it to quickly investigate something which
occured when perusing the first grep. So it would be logical to have a
means to easily close the current grep buffer and return to the
previous one.

Currently, in your implementation pressing 'q' in the grep buffer only
closes the current one leaving to the user to switch to the previous
grep buffer. Wouldn't make it more sense for q to switch to the last
recently used grep buffer if there is one? With an option maybe?

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

* RE: Nested grep
  2006-11-16  8:02                     ` spamfilteraccount
@ 2006-11-16 17:35                       ` Drew Adams
  0 siblings, 0 replies; 20+ messages in thread
From: Drew Adams @ 2006-11-16 17:35 UTC (permalink / raw)


> > OK. I just added similar commands to compile+20.el, for use with Emacs
> > versions prior to 22:
> http://www.emacswiki.org/cgi-bin/wiki/compile%2b20.el.
> > However, since there is no grep-specific keymap prior to Emacs
> 22, I have
> > not bound the new commands.
> >
>
> Thanks, it's working well.  Though I'm missing something like I
> originally suggested: an easy way to go back to the previous grep
> buffer.
>
> I think when one opens a new grep buffer (while keeping the previous
> one) then one usually does it to quickly investigate something which
> occured when perusing the first grep. So it would be logical to have a
> means to easily close the current grep buffer and return to the
> previous one.
>
> Currently, in your implementation pressing 'q' in the grep buffer only
> closes the current one leaving to the user to switch to the previous
> grep buffer. Wouldn't make it more sense for q to switch to the last
> recently used grep buffer if there is one? With an option maybe?

Hi Tamas. Just use `choose-grep-buffer', instead of `q'. That will switch to
another grep buffer in place of the current one. The default value is now
the last-used grep buffer, so just use M-n to get that.

Download the latest compile+20.el - I just added the completion default. I
hadn't bothered to do that before (grep+.el uses `grep-last-buffer', which
isn't defined in Emacs 20).

HTH - Drew

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

* RE: Nested grep
  2006-11-15 17:57             ` Peter Lee
@ 2006-11-17 16:09               ` Drew Adams
  0 siblings, 0 replies; 20+ messages in thread
From: Drew Adams @ 2006-11-17 16:09 UTC (permalink / raw)


>     > http://www.emacswiki.org/cgi-bin/wiki/grep%2b.el.
> 
> Drew, I like this package, but have one problem with it.
> 
> I have to hit 'n' twice to advance one error.
> However 'p' does not do this, so I'm assuming
> it's a bug.

Thanks for this bug report, Peter.
Please try the latest version - this should be fixed now.

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

* Re: Nested grep
       [not found] <mailman.754.1163779854.2155.help-gnu-emacs@gnu.org>
@ 2006-11-17 17:59 ` Peter Lee
  0 siblings, 0 replies; 20+ messages in thread
From: Peter Lee @ 2006-11-17 17:59 UTC (permalink / raw)


>>>> Drew Adams writes:

    > Please try the latest version - this should be fixed now.

Perfect... works great now. Thanks.

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

end of thread, other threads:[~2006-11-17 17:59 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-14 13:35 Nested grep spamfilteraccount
2006-11-14 14:55 ` Robert Thorpe
2006-11-14 15:02 ` Drew Adams
     [not found] ` <mailman.569.1163516549.2155.help-gnu-emacs@gnu.org>
2006-11-14 16:00   ` spamfilteraccount
2006-11-14 16:11 ` Markus Triska
2006-11-14 16:34   ` spamfilteraccount
2006-11-14 16:40     ` Markus Triska
2006-11-14 17:00       ` spamfilteraccount
2006-11-14 17:32         ` spamfilteraccount
2006-11-14 21:54           ` Drew Adams
     [not found]           ` <mailman.604.1163541320.2155.help-gnu-emacs@gnu.org>
2006-11-15  6:35             ` spamfilteraccount
2006-11-15 16:36               ` Drew Adams
     [not found]               ` <mailman.653.1163608715.2155.help-gnu-emacs@gnu.org>
2006-11-15 16:47                 ` spamfilteraccount
2006-11-15 19:02                   ` Drew Adams
     [not found]                   ` <mailman.666.1163617488.2155.help-gnu-emacs@gnu.org>
2006-11-16  8:02                     ` spamfilteraccount
2006-11-16 17:35                       ` Drew Adams
2006-11-15 17:57             ` Peter Lee
2006-11-17 16:09               ` Drew Adams
2006-11-14 18:21 ` Peter Dyballa
     [not found] <mailman.754.1163779854.2155.help-gnu-emacs@gnu.org>
2006-11-17 17:59 ` Peter Lee

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.