changeset 58625:31d0b9422d7b

simple.el (next-error-buffer-p): allow for inclusive and exclusive tests for finding a buffer (next-error-find-buffer): pass the exclusive and inclusive tests to next-error-buffer-p replace.el (occur-next-error): switch to the Occur buffer when appropriate, and use the exclusive filter to next-error-find-buffer to do it. Use the absolute value of the motion amount.
author Teodor Zlatanov <tzz@lifelogs.com>
date Mon, 29 Nov 2004 18:44:29 +0000
parents a322009ca3d0
children f6af195898b4
files lisp/ChangeLog lisp/replace.el lisp/simple.el
diffstat 3 files changed, 58 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Nov 29 15:58:15 2004 +0000
+++ b/lisp/ChangeLog	Mon Nov 29 18:44:29 2004 +0000
@@ -1,3 +1,15 @@
+2004-11-26  Teodor Zlatanov  <tzz@lifelogs.com>
+
+	* simple.el (next-error-buffer-p): allow for inclusive and
+	exclusive tests for finding a buffer
+	(next-error-find-buffer): pass the exclusive and inclusive tests
+	to next-error-buffer-p
+
+	* replace.el (occur-next-error): switch to the Occur buffer when
+	appropriate, and use the exclusive filter to
+	next-error-find-buffer to do it.  Use the absolute value of the
+	motion amount.  
+
 2004-11-29  Kenichi Handa  <handa@m17n.org>
 
 	* startup.el (command-line): Decode all buffer names by
--- a/lisp/replace.el	Mon Nov 29 15:58:15 2004 +0000
+++ b/lisp/replace.el	Mon Nov 29 18:44:29 2004 +0000
@@ -734,17 +734,23 @@
   "Move to the Nth (default 1) next match in an Occur mode buffer.
 Compatibility function for \\[next-error] invocations."
   (interactive "p")
-  (when reset
-    (occur-find-match 0 #'next-single-property-change "No first match"))
-  (occur-find-match
-   (prefix-numeric-value argp)
-   (if (> 0 (prefix-numeric-value argp))
-       #'previous-single-property-change
-     #'next-single-property-change)
-   "No more matches")
-  ;; In case the *Occur* buffer is visible in a nonselected window.
-  (set-window-point (get-buffer-window (current-buffer)) (point))
-  (occur-mode-goto-occurrence))
+  ;; we need to run occur-find-match from within the Occur buffer
+  (with-current-buffer 
+      (if (next-error-buffer-p (current-buffer))
+	  (current-buffer)
+	(next-error-find-buffer nil nil (lambda() (eq major-mode 'occur-mode))))
+    
+    (when reset
+      (goto-char (point-min)))
+    (occur-find-match
+     (abs (prefix-numeric-value argp))
+     (if (> 0 (prefix-numeric-value argp))
+	 #'previous-single-property-change
+       #'next-single-property-change)
+     "No more matches")
+    ;; In case the *Occur* buffer is visible in a nonselected window.
+    (set-window-point (get-buffer-window (current-buffer)) (point))
+    (occur-mode-goto-occurrence)))
 
 
 (defcustom list-matching-lines-default-context-lines 0
--- a/lisp/simple.el	Mon Nov 29 15:58:15 2004 +0000
+++ b/lisp/simple.el	Mon Nov 29 18:44:29 2004 +0000
@@ -123,21 +123,33 @@
 
 (make-variable-buffer-local 'next-error-function)
 
-(defsubst next-error-buffer-p (buffer &optional extra-test)
-  "Test if BUFFER is a next-error capable buffer."
+(defsubst next-error-buffer-p (buffer 
+			       &optional 
+			       extra-test-inclusive 
+			       extra-test-exclusive)
+  "Test if BUFFER is a next-error capable buffer.
+EXTRA-TEST-INCLUSIVE is called to allow extra buffers.
+EXTRA-TEST-INCLUSIVE is called to disallow buffers."
   (with-current-buffer buffer
-    (or (and extra-test (funcall extra-test))
-	next-error-function)))
-
-(defun next-error-find-buffer (&optional other-buffer extra-test)
-  "Return a next-error capable buffer."
+    (or (and extra-test-inclusive (funcall extra-test-inclusive))
+	(and (if extra-test-exclusive (funcall extra-test-exclusive) t)
+	 next-error-function))))
+
+(defun next-error-find-buffer (&optional other-buffer 
+					 extra-test-inclusive 
+					 extra-test-exclusive)
+  "Return a next-error capable buffer.
+OTHER-BUFFER will disallow the current buffer.
+EXTRA-TEST-INCLUSIVE is called to allow extra buffers.
+EXTRA-TEST-INCLUSIVE is called to disallow buffers."
   (or
    ;; 1. If one window on the selected frame displays such buffer, return it.
    (let ((window-buffers
           (delete-dups
            (delq nil (mapcar (lambda (w)
                                (if (next-error-buffer-p
-                                    (window-buffer w) extra-test)
+                                    (window-buffer w) 
+				    extra-test-inclusive extra-test-exclusive)
                                    (window-buffer w)))
                              (window-list))))))
      (if other-buffer
@@ -147,24 +159,29 @@
    ;; 2. If next-error-last-buffer is set to a live buffer, use that.
    (if (and next-error-last-buffer
             (buffer-name next-error-last-buffer)
-            (next-error-buffer-p next-error-last-buffer extra-test)
+            (next-error-buffer-p next-error-last-buffer 
+				 extra-test-inclusive extra-test-exclusive)
             (or (not other-buffer)
                 (not (eq next-error-last-buffer (current-buffer)))))
        next-error-last-buffer)
    ;; 3. If the current buffer is a next-error capable buffer, return it.
    (if (and (not other-buffer)
-            (next-error-buffer-p (current-buffer) extra-test))
+            (next-error-buffer-p (current-buffer) 
+				 extra-test-inclusive extra-test-exclusive))
        (current-buffer))
    ;; 4. Look for a next-error capable buffer in a buffer list.
    (let ((buffers (buffer-list)))
      (while (and buffers
-                 (or (not (next-error-buffer-p (car buffers) extra-test))
+                 (or (not (next-error-buffer-p 
+			   (car buffers) 
+			   extra-test-inclusive extra-test-exclusive))
                      (and other-buffer (eq (car buffers) (current-buffer)))))
        (setq buffers (cdr buffers)))
      (if buffers
          (car buffers)
        (or (and other-buffer
-                (next-error-buffer-p (current-buffer) extra-test)
+                (next-error-buffer-p (current-buffer) 
+				     extra-test-inclusive extra-test-exclusive)
                 ;; The current buffer is a next-error capable buffer.
                 (progn
                   (if other-buffer