comparison lisp/simple.el @ 56862:adba247afe3f

* simple.el (next-error-find-buffer): Move the rule "if current buffer is a next-error capable buffer" after the rule "if next-error-last-buffer is set to a live buffer". Simplify to test all rules in one `or'. (next-error): Doc fix.
author Juri Linkov <juri@jurta.org>
date Wed, 01 Sep 2004 17:05:59 +0000
parents 2e59d9187762
children c8bb5aca0581
comparison
equal deleted inserted replaced
56861:2e59d9187762 56862:adba247afe3f
89 "Test if BUFFER is a next-error capable buffer." 89 "Test if BUFFER is a next-error capable buffer."
90 (with-current-buffer buffer 90 (with-current-buffer buffer
91 (or (and extra-test (funcall extra-test)) 91 (or (and extra-test (funcall extra-test))
92 next-error-function))) 92 next-error-function)))
93 93
94 ;; Return a next-error capable buffer according to the following rules:
95 ;; 1. If the current buffer is a next-error capable buffer, return it.
96 ;; 2. If one window on the selected frame displays such buffer, return it.
97 ;; 3. If next-error-last-buffer is set to a live buffer, use that.
98 ;; 4. Otherwise, look for a next-error capable buffer in a buffer list.
99 ;; 5. Signal an error if there are none.
100 (defun next-error-find-buffer (&optional other-buffer extra-test) 94 (defun next-error-find-buffer (&optional other-buffer extra-test)
101 (if (and (not other-buffer) 95 "Return a next-error capable buffer."
102 (next-error-buffer-p (current-buffer) extra-test)) 96 (or
103 ;; The current buffer is a next-error capable buffer. 97 ;; 1. If one window on the selected frame displays such buffer, return it.
104 (current-buffer) 98 (let ((window-buffers
105 (or 99 (delete-dups
106 (let ((window-buffers 100 (delq nil (mapcar (lambda (w)
107 (delete-dups 101 (if (next-error-buffer-p
108 (delq nil 102 (window-buffer w) extra-test)
109 (mapcar (lambda (w) 103 (window-buffer w)))
110 (and (next-error-buffer-p (window-buffer w) extra-test) 104 (window-list))))))
111 (window-buffer w))) 105 (if other-buffer
112 (window-list)))))) 106 (setq window-buffers (delq (current-buffer) window-buffers)))
113 (if other-buffer 107 (if (eq (length window-buffers) 1)
114 (setq window-buffers (delq (current-buffer) window-buffers))) 108 (car window-buffers)))
115 (if (eq (length window-buffers) 1) 109 ;; 2. If next-error-last-buffer is set to a live buffer, use that.
116 (car window-buffers))) 110 (if (and next-error-last-buffer
117 (if (and next-error-last-buffer (buffer-name next-error-last-buffer) 111 (buffer-name next-error-last-buffer)
118 (next-error-buffer-p next-error-last-buffer extra-test) 112 (next-error-buffer-p next-error-last-buffer extra-test)
119 (or (not other-buffer) (not (eq next-error-last-buffer 113 (or (not other-buffer)
120 (current-buffer))))) 114 (not (eq next-error-last-buffer (current-buffer)))))
121 next-error-last-buffer 115 next-error-last-buffer)
122 (let ((buffers (buffer-list))) 116 ;; 3. If the current buffer is a next-error capable buffer, return it.
123 (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test)) 117 (if (and (not other-buffer)
124 (and other-buffer 118 (next-error-buffer-p (current-buffer) extra-test))
125 (eq (car buffers) (current-buffer))))) 119 (current-buffer))
126 (setq buffers (cdr buffers))) 120 ;; 4. Look for a next-error capable buffer in a buffer list.
127 (if buffers 121 (let ((buffers (buffer-list)))
128 (car buffers) 122 (while (and buffers
129 (or (and other-buffer 123 (or (not (next-error-buffer-p (car buffers) extra-test))
130 (next-error-buffer-p (current-buffer) extra-test) 124 (and other-buffer (eq (car buffers) (current-buffer)))))
131 ;; The current buffer is a next-error capable buffer. 125 (setq buffers (cdr buffers)))
132 (progn 126 (if buffers
133 (if other-buffer 127 (car buffers)
134 (message "This is the only next-error capable buffer.")) 128 (or (and other-buffer
135 (current-buffer))) 129 (next-error-buffer-p (current-buffer) extra-test)
136 (error "No next-error capable buffer found")))))))) 130 ;; 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"))))))
137 136
138 (defun next-error (&optional arg reset) 137 (defun next-error (&optional arg reset)
139 "Visit next next-error message and corresponding source code. 138 "Visit next next-error message and corresponding source code.
140 139
141 If all the error messages parsed so far have been processed already, 140 If all the error messages parsed so far have been processed already,
151 \\[next-error] normally uses the most recently started 150 \\[next-error] normally uses the most recently started
152 compilation, grep, or occur buffer. It can also operate on any 151 compilation, grep, or occur buffer. It can also operate on any
153 buffer with output from the \\[compile], \\[grep] commands, or, 152 buffer with output from the \\[compile], \\[grep] commands, or,
154 more generally, on any buffer in Compilation mode or with 153 more generally, on any buffer in Compilation mode or with
155 Compilation Minor mode enabled, or any buffer in which 154 Compilation Minor mode enabled, or any buffer in which
156 `next-error-function' is bound to an appropriate 155 `next-error-function' is bound to an appropriate function.
157 function. To specify use of a particular buffer for error 156 To specify use of a particular buffer for error messages, type
158 messages, type \\[next-error] in that buffer. 157 \\[next-error] in that buffer when it is the only one displayed
158 in the current frame.
159 159
160 Once \\[next-error] has chosen the buffer for error messages, 160 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 161 it stays with that buffer until you use it in some other buffer which
162 uses Compilation mode or Compilation Minor mode. 162 uses Compilation mode or Compilation Minor mode.
163 163