Mercurial > emacs
comparison lisp/locate.el @ 90601:a1a25ac6c88a
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 427-436)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 134-136)
- Merge from emacs--devo--0
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-110
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 14 Sep 2006 09:24:00 +0000 |
parents | 138ce2701550 3e504dad08cd |
children | f1d13e615070 |
comparison
equal
deleted
inserted
replaced
90600:84dd84b43e1b | 90601:a1a25ac6c88a |
---|---|
112 (eval-when-compile | 112 (eval-when-compile |
113 (require 'dired)) | 113 (require 'dired)) |
114 | 114 |
115 ;; Variables | 115 ;; Variables |
116 | 116 |
117 (defvar locate-current-search nil) | |
117 (defvar locate-current-filter nil) | 118 (defvar locate-current-filter nil) |
118 | 119 |
119 (defgroup locate nil | 120 (defgroup locate nil |
120 "Interface to the locate command." | 121 "Interface to the locate command." |
121 :prefix "locate-" | 122 :prefix "locate-" |
287 (locate-cmd (car locate-cmd-list)) | 288 (locate-cmd (car locate-cmd-list)) |
288 (locate-cmd-args (cdr locate-cmd-list)) | 289 (locate-cmd-args (cdr locate-cmd-list)) |
289 (run-locate-command | 290 (run-locate-command |
290 (or (and current-prefix-arg (not locate-prompt-for-command)) | 291 (or (and current-prefix-arg (not locate-prompt-for-command)) |
291 (and (not current-prefix-arg) locate-prompt-for-command))) | 292 (and (not current-prefix-arg) locate-prompt-for-command))) |
293 locate-buffer | |
292 ) | 294 ) |
293 | 295 |
294 ;; Find the Locate buffer | 296 ;; Find the Locate buffer |
295 (save-window-excursion | 297 (setq locate-buffer (if (eq major-mode 'locate-mode) |
296 (set-buffer (get-buffer-create locate-buffer-name)) | 298 (current-buffer) |
299 (get-buffer-create locate-buffer-name))) | |
300 | |
301 (save-excursion | |
302 (set-buffer locate-buffer) | |
297 (locate-mode) | 303 (locate-mode) |
304 | |
298 (let ((inhibit-read-only t) | 305 (let ((inhibit-read-only t) |
299 (buffer-undo-list t)) | 306 (buffer-undo-list t)) |
300 (erase-buffer) | 307 (erase-buffer) |
301 | 308 |
302 (setq locate-current-filter filter) | 309 (set (make-local-variable 'locate-current-search) search-string) |
303 | 310 (set (make-local-variable 'locate-current-filter) filter) |
304 (if run-locate-command | 311 |
305 (shell-command search-string locate-buffer-name) | 312 (if run-locate-command |
306 (apply 'call-process locate-cmd nil t nil locate-cmd-args)) | 313 (shell-command search-string) |
307 | 314 (apply 'call-process locate-cmd nil t nil locate-cmd-args)) |
308 (and filter | 315 |
309 (locate-filter-output filter)) | 316 (and filter |
310 | 317 (locate-filter-output filter)) |
311 (locate-do-setup search-string) | 318 |
312 )) | 319 (locate-do-setup search-string))) |
313 (and (not (string-equal (buffer-name) locate-buffer-name)) | 320 |
314 (switch-to-buffer-other-window locate-buffer-name)) | 321 (unless (eq (current-buffer) locate-buffer) |
322 (switch-to-buffer-other-window locate-buffer)) | |
315 | 323 |
316 (run-hooks 'dired-mode-hook) | 324 (run-hooks 'dired-mode-hook) |
317 (dired-next-line 3) ;move to first matching file. | 325 (dired-next-line 3) ;move to first matching file. |
318 (run-hooks 'locate-post-command-hook) | 326 (run-hooks 'locate-post-command-hook) |
319 ) | 327 ) |
459 (setq major-mode 'locate-mode | 467 (setq major-mode 'locate-mode |
460 mode-name "Locate" | 468 mode-name "Locate" |
461 default-directory "/" | 469 default-directory "/" |
462 buffer-read-only t | 470 buffer-read-only t |
463 selective-display t) | 471 selective-display t) |
472 (buffer-disable-undo) | |
464 (dired-alist-add-1 default-directory (point-min-marker)) | 473 (dired-alist-add-1 default-directory (point-min-marker)) |
465 (set (make-local-variable 'dired-directory) "/") | 474 (set (make-local-variable 'dired-directory) "/") |
466 (set (make-local-variable 'dired-subdir-switches) locate-ls-subdir-switches) | 475 (set (make-local-variable 'dired-subdir-switches) locate-ls-subdir-switches) |
467 (setq dired-switches-alist nil) | 476 (setq dired-switches-alist nil) |
468 (make-local-variable 'directory-listing-before-filename-regexp) | 477 (make-local-variable 'directory-listing-before-filename-regexp) |
490 (save-excursion | 499 (save-excursion |
491 | 500 |
492 ;; Nothing returned from locate command? | 501 ;; Nothing returned from locate command? |
493 (and (eobp) | 502 (and (eobp) |
494 (progn | 503 (progn |
495 (kill-buffer locate-buffer-name) | 504 (let ((filter locate-current-filter)) ; local |
496 (if locate-current-filter | 505 (kill-buffer (current-buffer)) |
497 (error "Locate: no match for %s in database using filter %s" | 506 (if filter |
498 search-string locate-current-filter) | 507 (error "Locate: no match for %s in database using filter %s" |
499 (error "Locate: no match for %s in database" search-string)))) | 508 search-string filter) |
509 (error "Locate: no match for %s in database" search-string))))) | |
500 | 510 |
501 (locate-insert-header search-string) | 511 (locate-insert-header search-string) |
502 | 512 |
503 (while (not (eobp)) | 513 (while (not (eobp)) |
504 (insert-char ?\ locate-filename-indentation t) | 514 (insert-char ?\ locate-filename-indentation t) |
578 ;; From Stephen Eglen <stephen@cns.ed.ac.uk> | 588 ;; From Stephen Eglen <stephen@cns.ed.ac.uk> |
579 (defun locate-update (ignore1 ignore2) | 589 (defun locate-update (ignore1 ignore2) |
580 "Revert the *Locate* buffer. | 590 "Revert the *Locate* buffer. |
581 If `locate-update-when-revert' is non-nil, offer to update the | 591 If `locate-update-when-revert' is non-nil, offer to update the |
582 locate database using the shell command in `locate-update-command'." | 592 locate database using the shell command in `locate-update-command'." |
583 (let ((str (car locate-history-list))) | 593 (and locate-update-when-revert |
584 (and locate-update-when-revert | 594 (yes-or-no-p "Update locate database (may take a few seconds)? ") |
585 (yes-or-no-p "Update locate database (may take a few seconds)? ") | 595 ;; `expand-file-name' is used in order to autoload Tramp if |
586 ;; `expand-file-name' is used in order to autoload Tramp if | 596 ;; necessary. It cannot be loaded when `default-directory' |
587 ;; necessary. It cannot be loaded when `default-directory' | 597 ;; is remote. |
588 ;; is remote. | 598 (let ((default-directory (expand-file-name locate-update-path))) |
589 (let ((default-directory (expand-file-name locate-update-path))) | 599 (shell-command locate-update-command))) |
590 (shell-command locate-update-command))) | 600 (locate locate-current-search locate-current-filter)) |
591 (locate str))) | |
592 | 601 |
593 ;;; Modified three functions from `dired.el': | 602 ;;; Modified three functions from `dired.el': |
594 ;;; dired-find-directory, | 603 ;;; dired-find-directory, |
595 ;;; dired-find-directory-other-window | 604 ;;; dired-find-directory-other-window |
596 ;;; dired-get-filename | 605 ;;; dired-get-filename |