Back in 2016 I posted my emacs setup for finding files globally. It unifies find-file and switch-to-buffer, and also lets me find files without switching folders. I've been improving it since then and wanted to post an update.

Find files globally

The biggest change is speed. I profiled the code and found two bottlenecks in the construction of the global file list. The list is roughly 15000 elements, so I precomputed as much of that as I could, and the startup time went down from 0.8 seconds to 0.1 second. It feels instant now.

There are three components to this system.

1 Make a list of files

From an hourly cronjob, I make a global list of filenames that I am likely to work with. This is around 15000 on my system. I sort them so that the newer ones are closer to the top:

For the latter two, I gave the ivy a name with :caller 'amitp/ivy-all-files, and then 'amitp/ivy-all-files is the key used in the customization lists. I'm new to Ivy and don't understand why there are three different systems for customization.

6 Next steps

This is highly customized to my system so I don't think it'll directly be useful, but I hope you can take these pieces and use them for your own setup.

Things I'd like to do:

Prioritize the current project's files in the sort order

Highlight folders and current project files differently

Improve the match order to prefer matches towards the end of the filename, so that bar matches /foo/bar.txt before /bar/foo.txt

Collect data on which matches I actually select, so that I can adjust the sort order to better match what I want

Figure out how to integrate locate results into Ivy, like I have with Helm. I tried the multiple-source approach from here but it didn't display the main list until the locate was finished, which added too much latency.