diff options
author | Teodor Zlatanov <tzz@lifelogs.com> | 2004-11-29 18:44:29 +0000 |
---|---|---|
committer | Teodor Zlatanov <tzz@lifelogs.com> | 2004-11-29 18:44:29 +0000 |
commit | 5f9e0ca5dae5a442a210735e6357977a6807b815 (patch) | |
tree | 87e6c26b8cd40bbd2d0ee09feb89241afedf8438 /lisp/simple.el | |
parent | 2e66e5b785082ca0a50d4b03486ddb3e957153e6 (diff) | |
download | emacs-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/simple.el')
-rw-r--r-- | lisp/simple.el | 41 |
1 files changed, 29 insertions, 12 deletions
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 |