diff options
| author | Colin Walters | 2002-05-02 21:22:56 +0000 |
|---|---|---|
| committer | Colin Walters | 2002-05-02 21:22:56 +0000 |
| commit | 70ed2a76302d0c9b123c31db0d6439ae544a110a (patch) | |
| tree | 684acfae6d1140c76948f70141df110cc43c85bd | |
| parent | 307645975cf9964740f4de544718f3f344a0c99c (diff) | |
| download | emacs-70ed2a76302d0c9b123c31db0d6439ae544a110a.tar.gz emacs-70ed2a76302d0c9b123c31db0d6439ae544a110a.zip | |
(occur-mode-map): Bind "q" to `delete-window'.
(occur-1): If one of the buffers we're searching is the *Occur* buffer
itself, handle it by creating a temporary buffer. If any of the
buffers being searched are killed, note that in the search result
message. Also, set local variables before we possibly kill the
buffer.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/replace.el | 44 |
2 files changed, 43 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fcbf26fd828..42f5a361c47 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2002-05-02 Colin Walters <walters@verbum.org> | ||
| 2 | |||
| 3 | * replace.el (occur-mode-map): Bind "q" to `delete-window'. | ||
| 4 | (occur-1): If one of the buffers we're searching is the *Occur* | ||
| 5 | buffer itself, handle it by creating a temporary buffer. If any | ||
| 6 | of the buffers being searched are killed, note that in the search | ||
| 7 | result message. Also, set local variables before we possibly kill | ||
| 8 | the buffer. | ||
| 9 | |||
| 1 | 2002-05-02 Kim F. Storm <storm@cua.dk> | 10 | 2002-05-02 Kim F. Storm <storm@cua.dk> |
| 2 | 11 | ||
| 3 | * menu-bar.el (menu-bar-make-toggle): Added optional PROPS arg. | 12 | * menu-bar.el (menu-bar-make-toggle): Added optional PROPS arg. |
diff --git a/lisp/replace.el b/lisp/replace.el index e60f08f8f22..4294428c45e 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -445,6 +445,7 @@ end of the buffer." | |||
| 445 | (define-key map "\M-n" 'occur-next) | 445 | (define-key map "\M-n" 'occur-next) |
| 446 | (define-key map "\M-p" 'occur-prev) | 446 | (define-key map "\M-p" 'occur-prev) |
| 447 | (define-key map "g" 'revert-buffer) | 447 | (define-key map "g" 'revert-buffer) |
| 448 | (define-key map "q" 'delete-window) | ||
| 448 | map) | 449 | map) |
| 449 | "Keymap for `occur-mode'.") | 450 | "Keymap for `occur-mode'.") |
| 450 | 451 | ||
| @@ -679,27 +680,50 @@ See also `multi-occur'." | |||
| 679 | (buffer-list)))))) | 680 | (buffer-list)))))) |
| 680 | 681 | ||
| 681 | (defun occur-1 (regexp nlines bufs) | 682 | (defun occur-1 (regexp nlines bufs) |
| 682 | (let ((occur-buf (get-buffer-create "*Occur*"))) | 683 | (let ((occur-buf (get-buffer-create "*Occur*")) |
| 684 | (made-temp-buf nil) | ||
| 685 | (active-bufs (delq nil (mapcar #'(lambda (buf) | ||
| 686 | (when (buffer-live-p buf) buf)) | ||
| 687 | bufs)))) | ||
| 688 | ;; Handle the case where one of the buffers we're searching is the | ||
| 689 | ;; *Occur* buffer itself. | ||
| 690 | (when (memq occur-buf bufs) | ||
| 691 | (setq occur-buf (with-current-buffer occur-buf | ||
| 692 | (clone-buffer "*Occur-temp*")) | ||
| 693 | made-temp-buf t)) | ||
| 683 | (with-current-buffer occur-buf | 694 | (with-current-buffer occur-buf |
| 684 | (setq buffer-read-only nil) | 695 | (setq buffer-read-only nil) |
| 685 | (occur-mode) | 696 | (occur-mode) |
| 686 | (erase-buffer) | 697 | (erase-buffer) |
| 687 | (let ((count (occur-engine | 698 | (let ((count (occur-engine |
| 688 | regexp bufs occur-buf | 699 | regexp active-bufs occur-buf |
| 689 | (or nlines list-matching-lines-default-context-lines) | 700 | (or nlines list-matching-lines-default-context-lines) |
| 690 | (and case-fold-search | 701 | (and case-fold-search |
| 691 | (isearch-no-upper-case-p regexp t)) | 702 | (isearch-no-upper-case-p regexp t)) |
| 692 | nil nil nil nil))) | 703 | nil nil nil nil))) |
| 693 | (message "Searched %d buffers; %s matches for `%s'" (length bufs) | 704 | (let* ((diff (- (length bufs) (length active-bufs))) |
| 694 | (if (zerop count) | 705 | (msg (concat |
| 695 | "no" | 706 | (format "Searched %d buffers" (- (length bufs) diff)) |
| 696 | (format "%d" count)) | 707 | "%s; " |
| 697 | regexp) | 708 | (format "%s matches for `%s'" |
| 709 | (if (zerop count) | ||
| 710 | "no" | ||
| 711 | (format "%d" count)) | ||
| 712 | regexp)))) | ||
| 713 | (message msg (if (zerop diff) | ||
| 714 | "" | ||
| 715 | (format " (%d killed)" diff)))) | ||
| 716 | ;; If we had to make a temporary buffer, make it the *Occur* | ||
| 717 | ;; buffer now. | ||
| 718 | (when made-temp-buf | ||
| 719 | (with-current-buffer (get-buffer "*Occur*") | ||
| 720 | (kill-this-buffer)) | ||
| 721 | (rename-buffer "*Occur*")) | ||
| 722 | (setq occur-revert-arguments (list regexp nlines bufs) | ||
| 723 | buffer-read-only t) | ||
| 698 | (if (> count 0) | 724 | (if (> count 0) |
| 699 | (display-buffer occur-buf) | 725 | (display-buffer occur-buf) |
| 700 | (kill-buffer occur-buf))) | 726 | (kill-buffer occur-buf)))))) |
| 701 | (setq occur-revert-arguments (list regexp nlines bufs) | ||
| 702 | buffer-read-only t)))) | ||
| 703 | 727 | ||
| 704 | (defun occur-engine-add-prefix (lines) | 728 | (defun occur-engine-add-prefix (lines) |
| 705 | (mapcar | 729 | (mapcar |