# HG changeset patch # User Colin Walters # Date 1021261616 0 # Node ID 06efd70868351ef4dd1eb9e374cb605c249b7b7e # Parent 2aa98245ae6fe8db6b20ae0c32e2cf06ef11caee (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. diff -r 2aa98245ae6f -r 06efd7086835 lisp/replace.el --- 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)