Finding Files In Emacs Helm

Emacs' Helm is awesome. (I'm on a bit of a helm kick this week). You can [use it as a code-browser](http://blog.jenkster.com/2013/10/writing-a-spotify-client-in-16-minutes.html][use it to write a Spotify client]], you can [[http://blog.jenkster.com/2013/10/a-tip-for-navigating-clojure-files-in-emacs.html), but you can also use it for simple things like finding files in a directory, tree or project.

Setup

The setup's pretty easy. You'll want to install it of course:

M-x package-install
helm

And then edit your ~/.emacs and kick it off:

(helm-mode t)

How It Works

Most helm stuff involves calling (helm ...) function with some named arguments. Once you've found the ones you want, you'll want to bind it to a shortcut key, but for now let's try a basic invocation from the scratch buffer.

The two named arguments I use most are :sources and :buffer. :sources gives helm a list of places it can find search candidates. :buffer just names the buffer.

Some Searchy Examples

So, a simple way to search for files under the current directory is:

  (helm :sources '(helm-source-findutils)
        :buffer "*helm-findutils*")

It'll wait for you to enter at least 4 characters to narrow things down, then present a list.

We can add to that a few extra file-finding sources. If you package-install helm-ls-git, you can search the git project for the current file:

  (helm :sources '(helm-source-ls-git)
        :buffer "*helm-find-git*")

If you're using Linux or OSX, you can search machine-wide through locate:

  (helm :sources '(helm-source-locate)
        :buffer "*helm-locate*")

Mix & Match

And rather cool, you can mix all three of these sources, in whichever order you prefer:

  (helm :sources '(helm-source-findutils
                   helm-source-ls-git
                   helm-source-locate)
        :buffer "*helm-find-files*")

Each section will be filtered separately, and you can jump between them with C-o.

More Than You Asked For

And finally, here's a kitchen sink example. Have a look at the names of these sources and play around with any that sound useful:

  (helm :sources '(helm-source-findutils
                   helm-source-recentf
                   helm-source-bookmarks
                   helm-source-buffers-list
                   helm-source-google-suggest
                   helm-source-locate
                   helm-source-ls-git)
        :buffer "*helm all the things*")

And if that's not enough, with helm enabled, C-h v helm-source will give you even more to digest...