summaryrefslogtreecommitdiff
path: root/lisp/locate.el
diff options
context:
space:
mode:
authorPeter Breton <pbreton@attbi.com>2000-08-28 20:35:45 +0000
committerPeter Breton <pbreton@attbi.com>2000-08-28 20:35:45 +0000
commit8348e1f959d6923b051492f5b645bcfb52bbe00a (patch)
tree471956b2a6da8a07d99e51f0f5222b82f56f3269 /lisp/locate.el
parent2a371c3b91e9d17fccaaae82b55f2f2b8890343e (diff)
downloademacs-8348e1f959d6923b051492f5b645bcfb52bbe00a.tar.gz
(locate) Cleaned up locate command's interactive prompting
Thanks to Fran�s_Pinard <pinard@iro.umontreal.ca> for suggestions
Diffstat (limited to 'lisp/locate.el')
-rw-r--r--lisp/locate.el68
1 files changed, 38 insertions, 30 deletions
diff --git a/lisp/locate.el b/lisp/locate.el
index 363a4fe9ac9..ceb29458864 100644
--- a/lisp/locate.el
+++ b/lisp/locate.el
@@ -183,25 +183,33 @@ Otherwise, that behavior is invoked via a prefix argument."
(point)))))
;;;###autoload
-(defun locate (arg search-string &optional filter)
+(defun locate (search-string &optional filter)
"Run the program `locate', putting results in `*Locate*' buffer.
With prefix arg, prompt for the locate command to run."
(interactive
(list
- current-prefix-arg
- (if (or (and current-prefix-arg (not locate-prompt-for-command))
+ (if (or (and current-prefix-arg
+ (not locate-prompt-for-command))
(and (not current-prefix-arg) locate-prompt-for-command))
- (read-from-minibuffer "Run locate command: "
- nil nil nil 'locate-history-list)
- (read-from-minibuffer "Locate: " (locate-word-at-point) nil
- nil 'locate-history-list)
+ (let ((locate-cmd (funcall locate-make-command-line "")))
+ (read-from-minibuffer
+ "Run locate (like this): "
+ (cons
+ (concat (car locate-cmd) " "
+ (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* ((locate-cmd-list (funcall locate-make-command-line search-string))
(locate-cmd (car locate-cmd-list))
(locate-cmd-args (cdr locate-cmd-list))
(run-locate-command
- (or (and arg (not locate-prompt-for-command))
- (and (not arg) locate-prompt-for-command)))
+ (or (and current-prefix-arg (not locate-prompt-for-command))
+ (and (not current-prefix-arg) locate-prompt-for-command)))
)
;; Find the Locate buffer
@@ -219,7 +227,7 @@ With prefix arg, prompt for the locate command to run."
(and filter
(locate-filter-output filter))
- (locate-do-setup)
+ (locate-do-setup search-string)
)
(and (not (string-equal (buffer-name) locate-buffer-name))
(switch-to-buffer-other-window locate-buffer-name))
@@ -240,7 +248,7 @@ shown; this is often useful to constrain a big search."
nil 'locate-history-list)
(read-from-minibuffer "Filter: " nil nil
nil 'locate-grep-history-list)))
- (locate nil search-string filter))
+ (locate search-string filter))
(defun locate-filter-output (filter)
"Filter output from the locate command."
@@ -339,26 +347,26 @@ shown; this is often useful to constrain a big search."
(setq revert-buffer-function 'locate-update)
(run-hooks 'locate-mode-hook))
-(defun locate-do-setup ()
- (let ((search-string (car locate-history-list)))
- (goto-char (point-min))
- (save-excursion
+(defun locate-do-setup (search-string)
+ (goto-char (point-min))
+ (save-excursion
- ;; Nothing returned from locate command?
- (and (eobp)
- (progn
- (kill-buffer locate-buffer-name)
- (if locate-current-filter
- (error "Locate: no match for %s in database using filter %s"
- search-string locate-current-filter)
- (error "Locate: no match for %s in database" search-string))))
+ ;; Nothing returned from locate command?
+ (and (eobp)
+ (progn
+ (kill-buffer locate-buffer-name)
+ (if locate-current-filter
+ (error "Locate: no match for %s in database using filter %s"
+ search-string locate-current-filter)
+ (error "Locate: no match for %s in database" search-string))))
- (locate-insert-header search-string)
+ (locate-insert-header search-string)
- (while (not (eobp))
- (insert-char ?\ locate-filename-indentation t)
- (locate-set-properties)
- (forward-line 1)))))
+ (while (not (eobp))
+ (insert-char ?\ locate-filename-indentation t)
+ (locate-set-properties)
+ (forward-line 1)))
+ (goto-char (point-min)))
(defun locate-set-properties ()
(save-excursion
@@ -430,7 +438,7 @@ Database is updated using the shell command in `locate-update-command'."
(let ((str (car locate-history-list)))
(cond ((yes-or-no-p "Update locate database (may take a few seconds)? ")
(shell-command locate-update-command)
- (locate nil str)))))
+ (locate str)))))
;;; Modified three functions from `dired.el':
;;; dired-find-directory,
@@ -496,7 +504,7 @@ Database is updated using the shell command in `locate-update-command'."
(list (concat "--database="
(expand-file-name database))
string))))))
- (locate nil search-string)))
+ (locate search-string)))
(provide 'locate)