summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorTeodor Zlatanov <tzz@lifelogs.com>2004-11-29 18:44:29 +0000
committerTeodor Zlatanov <tzz@lifelogs.com>2004-11-29 18:44:29 +0000
commit5f9e0ca5dae5a442a210735e6357977a6807b815 (patch)
tree87e6c26b8cd40bbd2d0ee09feb89241afedf8438 /lisp
parent2e66e5b785082ca0a50d4b03486ddb3e957153e6 (diff)
downloademacs-5f9e0ca5dae5a442a210735e6357977a6807b815.tar.gz
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/replace.el28
-rw-r--r--lisp/simple.el41
3 files changed, 58 insertions, 23 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f7315a26c4c..ea97b407700 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -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
diff --git a/lisp/replace.el b/lisp/replace.el
index 97b05cbc80a..24a6436b4c3 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -734,17 +734,23 @@ Alternatively, click \\[occur-mode-mouse-goto] on an item to go to it.
"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
diff --git a/lisp/simple.el b/lisp/simple.el
index 3fb388c8867..f591559b8aa 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -123,21 +123,33 @@ to navigate in it.")
(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 @@ to navigate in it.")
;; 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