Thursday, December 09, 2010

Emacs Find File in Project

Note: This is already out of date. I have found, forked, and tweaked a github repo that did most of what I wanted and my version can be found there. Further tweaks may include caching and other speed increases for large projects.

Increasingly for Java projects I've been relying on IntelliJ IDEA, an amazing IDE. There are still times, however, when I need the sharp tool capabilities of Emacs. I've never been completely satisfied with the "find file in project" capabilities I have been able to configure in Emacs (especially after using IntelliJ IDEA) so I set out to fix that. Building on the ideas found in Stuart Halloway's What you can learn from ido.el and the find file in project snippet given on the emacs wiki page for ido.el I can up with the following improved find file in project approach - well actually two approaches as I have created approaches that gather their file lists from either 1) a TAG file or 2) by issuing a shell find command.

The main tweaks provided are:

  • I am limiting the search to file name rather than full path. This makes the flex finding much more effective and much faster when working with large projects
  • I turn on case sensitive searching making capital letter camel case matching work very well
  • Name conflicts are handled by a second disambiguation prompt.

I'm sure there is still plenty of room for improvement here so you can check for updates in my .emacs file. The following indicates the present state of things with hopefully enough comments so that you can follow along: