91 |
(or (and extra-test (funcall extra-test)) |
(or (and extra-test (funcall extra-test)) |
92 |
next-error-function))) |
next-error-function))) |
93 |
|
|
|
;; Return a next-error capable buffer according to the following rules: |
|
|
;; 1. If the current buffer is a next-error capable buffer, return it. |
|
|
;; 2. If one window on the selected frame displays such buffer, return it. |
|
|
;; 3. If next-error-last-buffer is set to a live buffer, use that. |
|
|
;; 4. Otherwise, look for a next-error capable buffer in a buffer list. |
|
|
;; 5. Signal an error if there are none. |
|
94 |
(defun next-error-find-buffer (&optional other-buffer extra-test) |
(defun next-error-find-buffer (&optional other-buffer extra-test) |
95 |
(if (and (not other-buffer) |
"Return a next-error capable buffer." |
96 |
(next-error-buffer-p (current-buffer) extra-test)) |
(or |
97 |
;; The current buffer is a next-error capable buffer. |
;; 1. If one window on the selected frame displays such buffer, return it. |
98 |
(current-buffer) |
(let ((window-buffers |
99 |
(or |
(delete-dups |
100 |
(let ((window-buffers |
(delq nil (mapcar (lambda (w) |
101 |
(delete-dups |
(if (next-error-buffer-p |
102 |
(delq nil |
(window-buffer w) extra-test) |
103 |
(mapcar (lambda (w) |
(window-buffer w))) |
104 |
(and (next-error-buffer-p (window-buffer w) extra-test) |
(window-list)))))) |
105 |
(window-buffer w))) |
(if other-buffer |
106 |
(window-list)))))) |
(setq window-buffers (delq (current-buffer) window-buffers))) |
107 |
(if other-buffer |
(if (eq (length window-buffers) 1) |
108 |
(setq window-buffers (delq (current-buffer) window-buffers))) |
(car window-buffers))) |
109 |
(if (eq (length window-buffers) 1) |
;; 2. If next-error-last-buffer is set to a live buffer, use that. |
110 |
(car window-buffers))) |
(if (and next-error-last-buffer |
111 |
(if (and next-error-last-buffer (buffer-name next-error-last-buffer) |
(buffer-name next-error-last-buffer) |
112 |
(next-error-buffer-p next-error-last-buffer extra-test) |
(next-error-buffer-p next-error-last-buffer extra-test) |
113 |
(or (not other-buffer) (not (eq next-error-last-buffer |
(or (not other-buffer) |
114 |
(current-buffer))))) |
(not (eq next-error-last-buffer (current-buffer))))) |
115 |
next-error-last-buffer |
next-error-last-buffer) |
116 |
(let ((buffers (buffer-list))) |
;; 3. If the current buffer is a next-error capable buffer, return it. |
117 |
(while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test)) |
(if (and (not other-buffer) |
118 |
(and other-buffer |
(next-error-buffer-p (current-buffer) extra-test)) |
119 |
(eq (car buffers) (current-buffer))))) |
(current-buffer)) |
120 |
(setq buffers (cdr buffers))) |
;; 4. Look for a next-error capable buffer in a buffer list. |
121 |
(if buffers |
(let ((buffers (buffer-list))) |
122 |
(car buffers) |
(while (and buffers |
123 |
(or (and other-buffer |
(or (not (next-error-buffer-p (car buffers) extra-test)) |
124 |
(next-error-buffer-p (current-buffer) extra-test) |
(and other-buffer (eq (car buffers) (current-buffer))))) |
125 |
;; The current buffer is a next-error capable buffer. |
(setq buffers (cdr buffers))) |
126 |
(progn |
(if buffers |
127 |
(if other-buffer |
(car buffers) |
128 |
(message "This is the only next-error capable buffer.")) |
(or (and other-buffer |
129 |
(current-buffer))) |
(next-error-buffer-p (current-buffer) extra-test) |
130 |
(error "No next-error capable buffer found")))))))) |
;; The current buffer is a next-error capable buffer. |
131 |
|
(progn |
132 |
|
(if other-buffer |
133 |
|
(message "This is the only next-error capable buffer")) |
134 |
|
(current-buffer))) |
135 |
|
(error "No next-error capable buffer found")))))) |
136 |
|
|
137 |
(defun next-error (&optional arg reset) |
(defun next-error (&optional arg reset) |
138 |
"Visit next next-error message and corresponding source code. |
"Visit next next-error message and corresponding source code. |
152 |
buffer with output from the \\[compile], \\[grep] commands, or, |
buffer with output from the \\[compile], \\[grep] commands, or, |
153 |
more generally, on any buffer in Compilation mode or with |
more generally, on any buffer in Compilation mode or with |
154 |
Compilation Minor mode enabled, or any buffer in which |
Compilation Minor mode enabled, or any buffer in which |
155 |
`next-error-function' is bound to an appropriate |
`next-error-function' is bound to an appropriate function. |
156 |
function. To specify use of a particular buffer for error |
To specify use of a particular buffer for error messages, type |
157 |
messages, type \\[next-error] in that buffer. |
\\[next-error] in that buffer when it is the only one displayed |
158 |
|
in the current frame. |
159 |
|
|
160 |
Once \\[next-error] has chosen the buffer for error messages, |
Once \\[next-error] has chosen the buffer for error messages, |
161 |
it stays with that buffer until you use it in some other buffer which |
it stays with that buffer until you use it in some other buffer which |