aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorColin Walters2002-05-13 03:46:56 +0000
committerColin Walters2002-05-13 03:46:56 +0000
commite16907837c044adf40e009651d9173275e95fb3e (patch)
tree2d19eb807c6507e1bd6679579aa9467f075ca8f4 /lisp/replace.el
parent14323818764cb0bb08eb3e08ab1f85a360940adf (diff)
downloademacs-e16907837c044adf40e009651d9173275e95fb3e.tar.gz
emacs-e16907837c044adf40e009651d9173275e95fb3e.zip
(occur-1): New optional argument `buf-name'.
(occur-revert-function): Use it. (occur-1): Handle plurals. (occur-engine): If there are no more matches, then finish searching the current buffer.
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el31
1 files changed, 20 insertions, 11 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 855a59085e6..d146ef15489 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -476,7 +476,7 @@ Alternatively, click \\[occur-mode-mouse-goto] on an item to go to it.
476 476
477(defun occur-revert-function (ignore1 ignore2) 477(defun occur-revert-function (ignore1 ignore2)
478 "Handle `revert-buffer' for Occur mode buffers." 478 "Handle `revert-buffer' for Occur mode buffers."
479 (apply 'occur-1 occur-revert-arguments)) 479 (apply 'occur-1 (append occur-revert-arguments (list (buffer-name)))))
480 480
481(defun occur-mode-mouse-goto (event) 481(defun occur-mode-mouse-goto (event)
482 "In Occur mode, go to the occurrence whose line you click on." 482 "In Occur mode, go to the occurrence whose line you click on."
@@ -678,8 +678,10 @@ See also `multi-occur'."
678 buf)) 678 buf))
679 (buffer-list)))))) 679 (buffer-list))))))
680 680
681(defun occur-1 (regexp nlines bufs) 681(defun occur-1 (regexp nlines bufs &optional buf-name)
682 (let ((occur-buf (get-buffer-create "*Occur*")) 682 (unless buf-name
683 (setq buf-name "*Occur*"))
684 (let ((occur-buf (get-buffer-create buf-name))
683 (made-temp-buf nil) 685 (made-temp-buf nil)
684 (active-bufs (delq nil (mapcar #'(lambda (buf) 686 (active-bufs (delq nil (mapcar #'(lambda (buf)
685 (when (buffer-live-p buf) buf)) 687 (when (buffer-live-p buf) buf))
@@ -701,13 +703,17 @@ See also `multi-occur'."
701 (isearch-no-upper-case-p regexp t)) 703 (isearch-no-upper-case-p regexp t))
702 nil nil nil nil))) 704 nil nil nil nil)))
703 (let* ((diff (- (length bufs) (length active-bufs))) 705 (let* ((diff (- (length bufs) (length active-bufs)))
706 (bufcount (- (length bufs) diff))
704 (msg (concat 707 (msg (concat
705 (format "Searched %d buffers" (- (length bufs) diff)) 708 (format "Searched %d buffer%s" bufcount (if (= bufcount 1) "" "s"))
706 "%s; " 709 "%s; "
707 (format "%s matches for `%s'" 710 (format "%s match%s for `%s'"
708 (if (zerop count) 711 (if (zerop count)
709 "no" 712 "no"
710 (format "%d" count)) 713 (format "%d" count))
714 (if (= count 1)
715 ""
716 "es")
711 regexp)))) 717 regexp))))
712 (message msg (if (zerop diff) 718 (message msg (if (zerop diff)
713 "" 719 ""
@@ -715,9 +721,9 @@ See also `multi-occur'."
715 ;; If we had to make a temporary buffer, make it the *Occur* 721 ;; If we had to make a temporary buffer, make it the *Occur*
716 ;; buffer now. 722 ;; buffer now.
717 (when made-temp-buf 723 (when made-temp-buf
718 (with-current-buffer (get-buffer "*Occur*") 724 (with-current-buffer (get-buffer buf-name)
719 (kill-this-buffer)) 725 (kill-buffer (current-buffer)))
720 (rename-buffer "*Occur*")) 726 (rename-buffer buf-name))
721 (setq occur-revert-arguments (list regexp nlines bufs) 727 (setq occur-revert-arguments (list regexp nlines bufs)
722 buffer-read-only t) 728 buffer-read-only t)
723 (if (> count 0) 729 (if (> count 0)
@@ -817,9 +823,12 @@ See also `multi-occur'."
817 mouse-face highlight help-echo 823 mouse-face highlight help-echo
818 "mouse-2: go to this occurrence"))))) 824 "mouse-2: go to this occurrence")))))
819 (goto-char endpt)) 825 (goto-char endpt))
820 (setq lines (1+ lines)) 826 (if endpt
821 ;; On to the next match... 827 (progn
822 (forward-line 1)))) 828 (setq lines (1+ lines))
829 ;; On to the next match...
830 (forward-line 1))
831 (goto-char (point-max))))))
823 (when (not (zerop matches)) ;; is the count zero? 832 (when (not (zerop matches)) ;; is the count zero?
824 (with-current-buffer out-buf 833 (with-current-buffer out-buf
825 (goto-char headerpt) 834 (goto-char headerpt)