locate and spotlight
Published 2007-03-02 @ 14:16
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
customize. I did that for a few weeks but I like the flexibility of having both available.