On 5/30/2014 9:54 AM, Marko Rauhamaa wrote:
Rustom Mody <rustompm...@gmail.com>:

3. Search unopened files (grep) for a string or re.

How do you do this with emacs?
I find a menagerie of greppish commands -- rgrep, lgrep, grep-find etc

To grep for a pattern in the directory of the active buffer:

    M-x grep
    Run grep (like this): grep -nH -e

Complete the grep command:

    Run grep (like this): grep -nH -e class *.py

and hit ENTER. Feel free to modify the command from grep to egrep, for
example. I often replace -e with -i.

To grep for a pattern in any subdirectory:

    M-x grep
    Run grep (like this): grep -nH -r assert .

or:

    M-x grep-find
    Run find (like this): find . -type f -exec grep -nH -e assert {} +

Again, you can modify the command freely:

    M-x grep-find
    Run find (like this): find . -name '*.py' -exec grep -nH -e assert {} +

Thank you for the answer. I once had things like this memorized, but now I prefer Idle's dialog, with selected text (if any) and the full path of the current directory (+/.py) pre-inserted as target and search directory, and options as radiobuttons (remembered from my last search) ...

You will get a list of hits in a new buffer. You can use the C-x `
command to traverse them in order, but there are many other ways.

and a scrollable window for results ;-).

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to