Trailing whitespace deleted.
[bpt/emacs.git] / lisp / locate.el
index ceb2945..40e8ddc 100644 (file)
@@ -1,6 +1,6 @@
 ;;; locate.el --- interface to the locate command
 
-;; Copyright (C) 1996, 1998 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1998, 2001 Free Software Foundation, Inc.
 
 ;; Author: Peter Breton <pbreton@cs.umb.edu>
 ;; Keywords: unix files
@@ -199,11 +199,18 @@ With prefix arg, prompt for the locate command to run."
                       (mapconcat 'identity (cdr locate-cmd) " "))
                       (+ 2 (length (car locate-cmd))))
              nil nil 'locate-history-list))
-        (read-from-minibuffer
-         "Locate: "
-         (locate-word-at-point)
-         nil nil 'locate-history-list)
-        )))
+        (let* ((default (locate-word-at-point))
+              (input
+               (read-from-minibuffer
+                (if  (> (length default) 0)
+                    (format "Locate (default `%s'): " default)
+                  (format "Locate: "))
+                nil nil nil 'locate-history-list default t)))
+              (and (equal input "") default
+                   (setq input default))
+              input))))
+  (if (equal search-string "")
+      (error "Please specify a filename to search for"))
   (let* ((locate-cmd-list (funcall locate-make-command-line search-string))
         (locate-cmd (car locate-cmd-list))
         (locate-cmd-args (cdr locate-cmd-list))
@@ -233,6 +240,7 @@ With prefix arg, prompt for the locate command to run."
        (switch-to-buffer-other-window locate-buffer-name))
 
     (run-hooks 'dired-mode-hook)
+    (dired-next-line 2)                        ;move to first matching file.
     (run-hooks 'locate-post-command-hook)
     )
   )
@@ -404,9 +412,9 @@ shown; this is often useful to constrain a big search."
              (append (list locate-current-filter) locate-format-args)))
 
     (setq locate-format-string
-         (concat locate-format-string ": \n\n")
+         (concat locate-format-string ":\n\n")
          locate-regexp-match
-         (concat locate-regexp-match ": \n"))
+         (concat locate-regexp-match ":\n"))
 
     (insert (apply 'format locate-format-string (reverse locate-format-args)))