1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-23 18:47:57 +00:00

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.
This commit is contained in:
Teodor Zlatanov 2004-11-29 18:44:29 +00:00
parent 2e66e5b785
commit 5f9e0ca5da
3 changed files with 57 additions and 22 deletions

View File

@ -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

View File

@ -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

View File

@ -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)))
(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)
"Return a next-error capable buffer."
(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