aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/locate.el68
2 files changed, 41 insertions, 30 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e0ad422408f..71d72b46533 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12000-08-28 Peter Breton <pbreton@ne.mediaone.net> 12000-08-28 Peter Breton <pbreton@ne.mediaone.net>
2 2
3 * locate.el (locate): Cleaned up locate command's interactive prompting
4 Thanks to François_Pinard <pinard@iro.umontreal.ca> for suggestions.
5
3 * filecache.el (file-cache-case-fold-search): New variable 6 * filecache.el (file-cache-case-fold-search): New variable
4 (file-cache-assoc-function): New variable 7 (file-cache-assoc-function): New variable
5 (file-cache-minibuffer-complete): Use file-cache-assoc-function. 8 (file-cache-minibuffer-complete): Use file-cache-assoc-function.
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."
183 (point))))) 183 (point)))))
184 184
185;;;###autoload 185;;;###autoload
186(defun locate (arg search-string &optional filter) 186(defun locate (search-string &optional filter)
187 "Run the program `locate', putting results in `*Locate*' buffer. 187 "Run the program `locate', putting results in `*Locate*' buffer.
188With prefix arg, prompt for the locate command to run." 188With prefix arg, prompt for the locate command to run."
189 (interactive 189 (interactive
190 (list 190 (list
191 current-prefix-arg 191 (if (or (and current-prefix-arg
192 (if (or (and current-prefix-arg (not locate-prompt-for-command)) 192 (not locate-prompt-for-command))
193 (and (not current-prefix-arg) locate-prompt-for-command)) 193 (and (not current-prefix-arg) locate-prompt-for-command))
194 (read-from-minibuffer "Run locate command: " 194 (let ((locate-cmd (funcall locate-make-command-line "")))
195 nil nil nil 'locate-history-list) 195 (read-from-minibuffer
196 (read-from-minibuffer "Locate: " (locate-word-at-point) nil 196 "Run locate (like this): "
197 nil 'locate-history-list) 197 (cons
198 (concat (car locate-cmd) " "
199 (mapconcat 'identity (cdr locate-cmd) " "))
200 (+ 2 (length (car locate-cmd))))
201 nil nil 'locate-history-list))
202 (read-from-minibuffer
203 "Locate: "
204 (locate-word-at-point)
205 nil nil 'locate-history-list)
198 ))) 206 )))
199 (let* ((locate-cmd-list (funcall locate-make-command-line search-string)) 207 (let* ((locate-cmd-list (funcall locate-make-command-line search-string))
200 (locate-cmd (car locate-cmd-list)) 208 (locate-cmd (car locate-cmd-list))
201 (locate-cmd-args (cdr locate-cmd-list)) 209 (locate-cmd-args (cdr locate-cmd-list))
202 (run-locate-command 210 (run-locate-command
203 (or (and arg (not locate-prompt-for-command)) 211 (or (and current-prefix-arg (not locate-prompt-for-command))
204 (and (not arg) locate-prompt-for-command))) 212 (and (not current-prefix-arg) locate-prompt-for-command)))
205 ) 213 )
206 214
207 ;; Find the Locate buffer 215 ;; Find the Locate buffer
@@ -219,7 +227,7 @@ With prefix arg, prompt for the locate command to run."
219 (and filter 227 (and filter
220 (locate-filter-output filter)) 228 (locate-filter-output filter))
221 229
222 (locate-do-setup) 230 (locate-do-setup search-string)
223 ) 231 )
224 (and (not (string-equal (buffer-name) locate-buffer-name)) 232 (and (not (string-equal (buffer-name) locate-buffer-name))
225 (switch-to-buffer-other-window locate-buffer-name)) 233 (switch-to-buffer-other-window locate-buffer-name))
@@ -240,7 +248,7 @@ shown; this is often useful to constrain a big search."
240 nil 'locate-history-list) 248 nil 'locate-history-list)
241 (read-from-minibuffer "Filter: " nil nil 249 (read-from-minibuffer "Filter: " nil nil
242 nil 'locate-grep-history-list))) 250 nil 'locate-grep-history-list)))
243 (locate nil search-string filter)) 251 (locate search-string filter))
244 252
245(defun locate-filter-output (filter) 253(defun locate-filter-output (filter)
246 "Filter output from the locate command." 254 "Filter output from the locate command."
@@ -339,26 +347,26 @@ shown; this is often useful to constrain a big search."
339 (setq revert-buffer-function 'locate-update) 347 (setq revert-buffer-function 'locate-update)
340 (run-hooks 'locate-mode-hook)) 348 (run-hooks 'locate-mode-hook))
341 349
342(defun locate-do-setup () 350(defun locate-do-setup (search-string)
343 (let ((search-string (car locate-history-list))) 351 (goto-char (point-min))
344 (goto-char (point-min)) 352 (save-excursion
345 (save-excursion
346 353
347 ;; Nothing returned from locate command? 354 ;; Nothing returned from locate command?
348 (and (eobp) 355 (and (eobp)
349 (progn 356 (progn
350 (kill-buffer locate-buffer-name) 357 (kill-buffer locate-buffer-name)
351 (if locate-current-filter 358 (if locate-current-filter
352 (error "Locate: no match for %s in database using filter %s" 359 (error "Locate: no match for %s in database using filter %s"
353 search-string locate-current-filter) 360 search-string locate-current-filter)
354 (error "Locate: no match for %s in database" search-string)))) 361 (error "Locate: no match for %s in database" search-string))))
355 362
356 (locate-insert-header search-string) 363 (locate-insert-header search-string)
357 364
358 (while (not (eobp)) 365 (while (not (eobp))
359 (insert-char ?\ locate-filename-indentation t) 366 (insert-char ?\ locate-filename-indentation t)
360 (locate-set-properties) 367 (locate-set-properties)
361 (forward-line 1))))) 368 (forward-line 1)))
369 (goto-char (point-min)))
362 370
363(defun locate-set-properties () 371(defun locate-set-properties ()
364 (save-excursion 372 (save-excursion
@@ -430,7 +438,7 @@ Database is updated using the shell command in `locate-update-command'."
430 (let ((str (car locate-history-list))) 438 (let ((str (car locate-history-list)))
431 (cond ((yes-or-no-p "Update locate database (may take a few seconds)? ") 439 (cond ((yes-or-no-p "Update locate database (may take a few seconds)? ")
432 (shell-command locate-update-command) 440 (shell-command locate-update-command)
433 (locate nil str))))) 441 (locate str)))))
434 442
435;;; Modified three functions from `dired.el': 443;;; Modified three functions from `dired.el':
436;;; dired-find-directory, 444;;; dired-find-directory,
@@ -496,7 +504,7 @@ Database is updated using the shell command in `locate-update-command'."
496 (list (concat "--database=" 504 (list (concat "--database="
497 (expand-file-name database)) 505 (expand-file-name database))
498 string)))))) 506 string))))))
499 (locate nil search-string))) 507 (locate search-string)))
500 508
501(provide 'locate) 509(provide 'locate)
502 510