Assume I have a bunch of directories and can guarantee that no two directories have a common filename (i.e. if foo/bar
exists, then bar
doesn't exist in any of the other directories). How can I setup emacs such that, given a hard-coded list in .emacs
of the directories to search, I can tell it to open bar
and it figures out that it's in foo
rather than me needing to tell it foo/bar
every time? It'd be even better if it handled name collisions somehow (e.g. a list of possible matches), but that's not mandatory as I'm certain in this case the directories have no filenames in common
Open files in emacs by filename instead of complete path
directoryemacsfilenames
Best Answer
As I write this, I discover
ifind-mode
, which looks spot on.Then type
M-x ifind-mode
to find a file in the specified directories (and subdirectories by default), with nifty completion.What I usually do is
e **/bar
from zsh (wheree
is an alias foremacsclient
). But that's disruptive if you're in Emacs already. Also, if there's a specific file I edit often, I leave it open (and I save my session).Out of the box, you can run
M-x find-dired
and specify arguments tofind
. But that's clumsy, at least for the case when you have a single match.ifind
makes this less clumsy.ido
has a bunch of features that may be useful, especially Use ido to find any file from the project.