changeset 45265:06efd7086835

(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.
author Colin Walters <walters@gnu.org>
date Mon, 13 May 2002 03:46:56 +0000
parents 2aa98245ae6f
children f93cb851704f
files lisp/replace.el
diffstat 1 files changed, 20 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/replace.el	Mon May 13 03:46:38 2002 +0000
+++ b/lisp/replace.el	Mon May 13 03:46:56 2002 +0000
@@ -476,7 +476,7 @@
 
 (defun occur-revert-function (ignore1 ignore2)
   "Handle `revert-buffer' for Occur mode buffers."
-  (apply 'occur-1 occur-revert-arguments))
+  (apply 'occur-1 (append occur-revert-arguments (list (buffer-name)))))
 
 (defun occur-mode-mouse-goto (event)
   "In Occur mode, go to the occurrence whose line you click on."
@@ -678,8 +678,10 @@
 			       buf))
 			   (buffer-list))))))
 
-(defun occur-1 (regexp nlines bufs)
-  (let ((occur-buf (get-buffer-create "*Occur*"))
+(defun occur-1 (regexp nlines bufs &optional buf-name)
+  (unless buf-name
+    (setq buf-name "*Occur*"))
+  (let ((occur-buf (get-buffer-create buf-name))
 	(made-temp-buf nil)
 	(active-bufs (delq nil (mapcar #'(lambda (buf)
 					   (when (buffer-live-p buf) buf))
@@ -701,13 +703,17 @@
 			 (isearch-no-upper-case-p regexp t))
 		    nil nil nil nil)))
 	(let* ((diff (- (length bufs) (length active-bufs)))
+	       (bufcount (- (length bufs) diff))
 	       (msg (concat
-		     (format "Searched %d buffers" (- (length bufs) diff))
+		     (format "Searched %d buffer%s" bufcount (if (= bufcount 1) "" "s"))
 		     "%s; "
-		     (format "%s matches for `%s'"
+		     (format "%s match%s for `%s'"
 			     (if (zerop count)
 				 "no"
 			       (format "%d" count))
+			     (if (= count 1)
+				 ""
+			       "es")
 			     regexp))))
 	  (message msg (if (zerop diff)
 			   ""
@@ -715,9 +721,9 @@
 	;; If we had to make a temporary buffer, make it the *Occur*
 	;; buffer now.
 	(when made-temp-buf
-	  (with-current-buffer (get-buffer "*Occur*")
-	    (kill-this-buffer))
-	  (rename-buffer "*Occur*"))
+	  (with-current-buffer (get-buffer buf-name)
+	    (kill-buffer (current-buffer)))
+	  (rename-buffer buf-name))
 	(setq occur-revert-arguments (list regexp nlines bufs)
 	      buffer-read-only t)
 	(if (> count 0)
@@ -817,9 +823,12 @@
 					  mouse-face highlight help-echo
 					  "mouse-2: go to this occurrence")))))
 		    (goto-char endpt))
-		  (setq lines (1+ lines))
-		  ;; On to the next match...
-		  (forward-line 1))))
+		  (if endpt
+		      (progn
+			(setq lines (1+ lines))
+			;; On to the next match...
+			(forward-line 1))
+		    (goto-char (point-max))))))
 	    (when (not (zerop matches)) ;; is the count zero?
 	      (with-current-buffer out-buf
 		(goto-char headerpt)