Tag Archives: locate

How to use Locate from Emacs on Windows

If you are like me, you like to:

  • Live in Emacs as much as possible to avoid context-switching
  • Set up Emacs so your environment abstracts the OS as much as possible

Being able to sit down at any of my computers and type M-x locate in Emacs is a requirement for me, even if It’s running Windows underneath.

In this post I’ll describe how to set up a locate(1) command on Windows 10, and how to access it from Emacs.

Step 1. Install Locate32

Download and install locate32 on your machine. It doesn’t have an installer, it just gives you a directory full of things, including the locate.exe binary. I put mine in "C:/Users/rml/Programs/locate32/", and added that location to my Windows %PATH%.

Step 2. Tell Emacs where to find it

In Emacs, set the value of the locate-command variable to wherever you ended up putting it. Here’s where it is on my machine:

(setq locate-command "c:/Users/rml/Programs/locate32/locate.exe")

Step 3. Locate all the things

Now when you run the M-x locate command from inside Emacs, it should give you a Dired buffer of results, the same way it does on other systems. Because it’s Dired, you can hit enter on a filename to visit it or mark files in various ways and then operate on them.

Here’s what it looks like on my Windows 10 laptop if I search for the text “svn”:

Advertisements