Follow Grep output script

How many times have you looked at the grep output to find where some data is defined or used? Jed can help you, using the script to move between files, and

Suppose that you want to know where the foo() function is called. you may type:

   $ rgrep -rn foo * | jed
(A nice trick, don't you think?) You'll see a buffer with the rgrep's output. Simply go to a line that looks promising, and invoke follow_grep() (my binding is Ctrl-V). You can use the walk_backward() function to return to the rgrep's output.

Thanks to Günter Milde, now has a separate mode! this mode makes the above trick far easier to use.
The followgrep mode is activated by the followgrep_mode() function. It is very useful if you autoload it, then you can write (on unix):

   $ fgrep -n bar * | jed -f followgrep_mode
like above, move to an interesting line, and time time simply press enter. You can close this buffer pressing 'q'. Note that this mode uses my file for movement, so if you want to return to followgrep buffer, invoke the walk_backward() function. (for a description of file, see my NTags page). You don't need to bind nothing, followgrep_mode() does it for you.

What if you are already editing some files, and you need to search something? Now you can also easily grep files without leaving your favorite editor (also this is code from Günter).
The function grep_and_follow() is what you want. It will ask for a string to search, and what files to grep. The results will be shown on a followgrep buffer.
By default it will use "grep -n" as command for seaching, but you can change it setting the custom variable JedGrepCommand.

You should know that the name is followgrep for historical reasons, now it does a lot more. It can follow #include directives. You may set what directories are searched for the include files by setting the variables Include_Braket_Dirs and Include_Quote_Dirs. (the defaults are nice for unices). If everything else fails, it tries to use the word under the cursor as a file name, and open it.

Get it here: followgrep.tar.gz

If you find all this useful, you should also take a look at file written by Marko Mahnic, while you are there, you may also look at some other nice scripts he wrote.

Back to home page.

Last Updated : Thu Nov  8 22:55:42 CET 2001