locate and spotlight

| | Comments (0)

locate and spotlight each have their pros and cons. I like both for different reasons, but recently I caught on to using mdfind (spotlight's command-line interface) to search for file-names only. It is still a little slower than locate (but not much) but always up to date:

(defun locate-make-mdfind-command-line (search-string)
  (list "mdfind" (concat "kMDItemDisplayName=*" search-string "*")))

(defun spotlight ()
  "Search for files by name using spotlight"
  (interactive)
  (let ((locate-command "mdfind")
        (locate-make-command-line 'locate-make-mdfind-command-line))
    (call-interactively 'locate nil)))

(defun spotlight-full ()
  "Search using spotlight"
  (interactive)
  (let ((locate-command "mdfind"))
    (call-interactively 'locate nil)))

If you're feeling adventurous, keep the first defun and set locate-command and locate-make-command-line via customize. I did that for a few weeks but I like the flexibility of having both available.

Leave a comment

About this Entry

This page contains a single entry by zenspider published on March 2, 2007 2:16 PM.

Adding blogging to hoe. was the previous entry in this blog.

autotest for emacs is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 4.32-en