Mercurial > emacs
comparison lisp/simple.el @ 89969:3219f94257bc
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-34
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-514
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-522
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 04 Sep 2004 09:14:28 +0000 |
parents | d8411455de48 c8bb5aca0581 |
children | cce1c0ee76ee |
comparison
equal
deleted
inserted
replaced
89968:1e9fa4848335 | 89969:3219f94257bc |
---|---|
63 (if (and (not (get-buffer-window buffer)) | 63 (if (and (not (get-buffer-window buffer)) |
64 (not (string-match "\\` " (buffer-name buffer)))) | 64 (not (string-match "\\` " (buffer-name buffer)))) |
65 (setq found buffer))) | 65 (setq found buffer))) |
66 (setq list (cdr list))) | 66 (setq list (cdr list))) |
67 (switch-to-buffer found))) | 67 (switch-to-buffer found))) |
68 | 68 |
69 ;;; next-error support framework | 69 ;;; next-error support framework |
70 (defvar next-error-last-buffer nil | 70 (defvar next-error-last-buffer nil |
71 "The most recent next-error buffer. | 71 "The most recent next-error buffer. |
72 A buffer becomes most recent when its compilation, grep, or | 72 A buffer becomes most recent when its compilation, grep, or |
73 similar mode is started, or when it is used with \\[next-error] | 73 similar mode is started, or when it is used with \\[next-error] |
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. |
137 | 131 (progn |
138 (defun next-error (arg &optional reset) | 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) | |
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, |
142 the message buffer is checked for new ones. | 141 the message buffer is checked for new ones. |
143 | 142 |
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 |
173 (defalias 'goto-next-locus 'next-error) | 173 (defalias 'goto-next-locus 'next-error) |
174 (defalias 'next-match 'next-error) | 174 (defalias 'next-match 'next-error) |
175 | 175 |
176 (define-key ctl-x-map "`" 'next-error) | 176 (define-key ctl-x-map "`" 'next-error) |
177 | 177 |
178 (defun previous-error (n) | 178 (defun previous-error (&optional n) |
179 "Visit previous next-error message and corresponding source code. | 179 "Visit previous next-error message and corresponding source code. |
180 | 180 |
181 Prefix arg N says how many error messages to move backwards (or | 181 Prefix arg N says how many error messages to move backwards (or |
182 forwards, if negative). | 182 forwards, if negative). |
183 | 183 |
184 This operates on the output from the \\[compile] and \\[grep] commands." | 184 This operates on the output from the \\[compile] and \\[grep] commands." |
185 (interactive "p") | 185 (interactive "p") |
186 (next-error (- n))) | 186 (next-error (- (or n 1)))) |
187 | 187 |
188 (defun first-error (n) | 188 (defun first-error (&optional n) |
189 "Restart at the first error. | 189 "Restart at the first error. |
190 Visit corresponding source code. | 190 Visit corresponding source code. |
191 With prefix arg N, visit the source code of the Nth error. | 191 With prefix arg N, visit the source code of the Nth error. |
192 This operates on the output from the \\[compile] command, for instance." | 192 This operates on the output from the \\[compile] command, for instance." |
193 (interactive "p") | 193 (interactive "p") |
194 (next-error n t)) | 194 (next-error n t)) |
195 | 195 |
196 (defun next-error-no-select (n) | 196 (defun next-error-no-select (&optional n) |
197 "Move point to the next error in the next-error buffer and highlight match. | 197 "Move point to the next error in the next-error buffer and highlight match. |
198 Prefix arg N says how many error messages to move forwards (or | 198 Prefix arg N says how many error messages to move forwards (or |
199 backwards, if negative). | 199 backwards, if negative). |
200 Finds and highlights the source line like \\[next-error], but does not | 200 Finds and highlights the source line like \\[next-error], but does not |
201 select the source buffer." | 201 select the source buffer." |
202 (interactive "p") | 202 (interactive "p") |
203 (next-error n) | 203 (let ((next-error-highlight next-error-highlight-no-select)) |
204 (next-error n)) | |
204 (pop-to-buffer next-error-last-buffer)) | 205 (pop-to-buffer next-error-last-buffer)) |
205 | 206 |
206 (defun previous-error-no-select (n) | 207 (defun previous-error-no-select (&optional n) |
207 "Move point to the previous error in the next-error buffer and highlight match. | 208 "Move point to the previous error in the next-error buffer and highlight match. |
208 Prefix arg N says how many error messages to move backwards (or | 209 Prefix arg N says how many error messages to move backwards (or |
209 forwards, if negative). | 210 forwards, if negative). |
210 Finds and highlights the source line like \\[previous-error], but does not | 211 Finds and highlights the source line like \\[previous-error], but does not |
211 select the source buffer." | 212 select the source buffer." |
212 (interactive "p") | 213 (interactive "p") |
213 (next-error-no-select (- n))) | 214 (next-error-no-select (- (or n 1)))) |
214 | 215 |
216 (defgroup next-error nil | |
217 "next-error support framework." | |
218 :group 'compilation | |
219 :version "21.4") | |
220 | |
221 (defface next-error | |
222 '((t (:inherit region))) | |
223 "Face used to highlight next error locus." | |
224 :group 'next-error | |
225 :version "21.4") | |
226 | |
227 (defcustom next-error-highlight 0.1 | |
228 "*Highlighting of locations in selected source buffers. | |
229 If number, highlight the locus in next-error face for given time in seconds. | |
230 If t, use persistent overlays fontified in next-error face. | |
231 If nil, don't highlight the locus in the source buffer. | |
232 If `fringe-arrow', indicate the locus by the fringe arrow." | |
233 :type '(choice (number :tag "Delay") | |
234 (const :tag "Persistent overlay" t) | |
235 (const :tag "No highlighting" nil) | |
236 (const :tag "Fringe arrow" 'fringe-arrow)) | |
237 :group 'next-error | |
238 :version "21.4") | |
239 | |
240 (defcustom next-error-highlight-no-select 0.1 | |
241 "*Highlighting of locations in non-selected source buffers. | |
242 If number, highlight the locus in next-error face for given time in seconds. | |
243 If t, use persistent overlays fontified in next-error face. | |
244 If nil, don't highlight the locus in the source buffer. | |
245 If `fringe-arrow', indicate the locus by the fringe arrow." | |
246 :type '(choice (number :tag "Delay") | |
247 (const :tag "Persistent overlay" t) | |
248 (const :tag "No highlighting" nil) | |
249 (const :tag "Fringe arrow" 'fringe-arrow)) | |
250 :group 'next-error | |
251 :version "21.4") | |
252 | |
215 ;;; | 253 ;;; |
216 | 254 |
217 (defun fundamental-mode () | 255 (defun fundamental-mode () |
218 "Major mode not specialized for anything in particular. | 256 "Major mode not specialized for anything in particular. |
219 Other major modes are defined by comparison with this one." | 257 Other major modes are defined by comparison with this one." |