0

I want to use the locate-file function in Emacs to find files quickly using file names. This link: http://www.gnu.org/software/emacs/elisp/html_node/Locating-Files.html says that there is a command function 'locate-file' for this purpose.

But when I try to use this function using: M-x locate-file it says [No match]. What could be the problem?

Strangely, when the function is present in describe-function!

Sabya
  • 11,534
  • 17
  • 67
  • 94

2 Answers2

2

Use icicle-locate or icicle-locate-file, in Icicles.

If you are on GNU/Linux or Unix then use icicle-locate, which takes advantage of the OS command locate, which uses a periodically updated index created by the OS command updatedb. Because of such indexing, locate (and hence icicle-locate) is extremely fast. And because this is Icicles you get the same incremental pattern matching you see in Anything (and more).

Drew
  • 29,895
  • 7
  • 74
  • 104
  • Both of them take a lot of time to create the index before suggesting the completion. Is there any way to keep the index generated and ready for use? – Sabya Oct 13 '11 at 07:11
  • `icicle-locate` should take no time at all -- it uses the external `locate` command. That external command does create and keep an (external) index. Or rather, it is the external program `updatedb` that creates or updates the index. Typically, `updatedb` is run periodically (e.g. daily) via a `cron` job. – Drew Nov 15 '11 at 22:16
1

locate-file is not for interactive use. There are lots of tools for finding files like dired-find.

event_jr
  • 17,467
  • 4
  • 47
  • 62
  • `dired-find` does not work the way I want. I just want to type the filename, say "foo.php", and it should search inside a given directory and list all the files like `anything` plugin. – Sabya Sep 29 '11 at 09:14
  • Well `locate-file` certainly doesn't do that. If you're happy with anything, then use that. – event_jr Sep 29 '11 at 09:35