views:

255

answers:

6

Hi.

I need some script that will find and open files by given pattern within current directory and it's subdirectories, kind of Snap Open for GEdit, fuzzyfinder for VIM and TextMate's Open Files.

any ideas?

+3  A: 

Not being familiar with any of the referenced libraries, I don't know if this is an exact answer, but it sounds like ido-mode will do at least some of what you're asking for, and it's bundled with Emacs as of version 22. Ido changes the way the default Emacs find-file and find-buffer keybindings work, supplying lists of completions for the strings you type and using the Enter key to accept the current selection (which can be a directory, allowing you to browse the directory structure from the minibuffer). Check the Ido EmacsWiki page for details.

Don Womick
+1  A: 

Not exactly what you're asking for, but close is ifind.el. To find all files that have frog in the name and the suffix .el:

M-x ifind /some/path/*frog*.el

That does do a search through all the subdirectories under /some/path.

It won't open all the files automatically, but instead pops up a *compilation* buffer that allows you to open them up either by clicking on the files or by doing M-x next-error (aka "C-x `").

This routine will open up each of the find results:

(defun visit-all-ifind-results ()
  "do next-error until there are no more"
  (interactive)
  (condition-case nil
      (while t
        (next-error))
    (error nil)))

So, with that, you could just follow up with M-x visit-all-ifind-results.

Trey Jackson
+5  A: 

You can do this in standard dired too.

First do

C-u s

which let's you change the dired ls command to -lR. Now you will have subdirectories in the dired buffer.

% m

Let's you mark all files matching a regexp.

To open the files use the command

`dired-do-find-marked-files'

you need (require 'dired-x) for this one.

justinhj
c-u sgives me 4 letters s
Daniel
In a dired window? It shouldn't. You could use M-x dired-sort-toggle-or-edit
justinhj
+3  A: 

Hi,

doesn't fulfill all your requirements, but one very easy option to open several files is to use glob patterns when you open a file (C-x C-f), like ~/prj/*/*.[hc].

danielpoe
Nice. Didn't know that one.
James Sulak
A: 

You will have to write this one yourself.

I occasionally like to open all relevant files in a project; for this I use eproject's eproject-open-all-project-files command.

jrockway
A: 

You may try ido mode. Read following for more options.

ido on emacswiki

Amol Gawai