Mercurial > emacs
comparison lisp/vc.el @ 2554:5686672705bf
(vc-revert-buffer1): Completely rewrote compilation reparsing code.
author | Roland McGrath <roland@gnu.org> |
---|---|
date | Mon, 19 Apr 1993 21:13:47 +0000 |
parents | 3af65d9b91e7 |
children | 9013d6e2b2e7 |
comparison
equal
deleted
inserted
replaced
2553:61e4e09e7243 | 2554:5686672705bf |
---|---|
231 (defun vc-revert-buffer1 (&optional arg no-confirm) | 231 (defun vc-revert-buffer1 (&optional arg no-confirm) |
232 ;; Most of this was shamelessly lifted from Sebastian Kremer's rcs.el mode. | 232 ;; Most of this was shamelessly lifted from Sebastian Kremer's rcs.el mode. |
233 ;; Revert buffer, try to keep point and mark where user expects them in spite | 233 ;; Revert buffer, try to keep point and mark where user expects them in spite |
234 ;; of changes because of expanded version-control key words. | 234 ;; of changes because of expanded version-control key words. |
235 ;; This is quite important since otherwise typeahead won't work as expected. | 235 ;; This is quite important since otherwise typeahead won't work as expected. |
236 ;; The algorithm for reparsing the *compilation* buffer if necessary was | |
237 ;; contributed by Johnathan Vail and Kevin Rodgers. | |
238 (interactive "P") | 236 (interactive "P") |
239 (widen) | 237 (widen) |
240 (let ((point-context (vc-position-context (point))) | 238 (let ((point-context (vc-position-context (point))) |
241 ;; Use mark-marker to avoid confusion in transient-mark-mode. | 239 ;; Use mark-marker to avoid confusion in transient-mark-mode. |
242 (mark-context (if (eq (marker-buffer (mark-marker)) (current-buffer)) | 240 (mark-context (if (eq (marker-buffer (mark-marker)) (current-buffer)) |
243 (vc-position-context (mark-marker)))) | 241 (vc-position-context (mark-marker)))) |
242 ;; Make the right thing happen in transient-mark-mode. | |
243 (mark-active nil) | |
244 ;; We may want to reparse the compilation buffer after revert | 244 ;; We may want to reparse the compilation buffer after revert |
245 (reparse (and (boundp 'compilation-error-list) | 245 (reparse (and (boundp 'compilation-error-list) ;compile loaded |
246 (listp compilation-error-list) | 246 (let ((curbuf (current-buffer))) |
247 (let ((buffer (current-buffer)) | 247 ;; Construct a list; each elt is nil or a buffer |
248 (errors compilation-error-list) | 248 ;; iff that buffer is a compilation output buffer |
249 (buffer-error-marked-p nil)) | 249 ;; that contains markers into the current buffer. |
250 (while (and errors (not buffer-error-marked-p)) | 250 (save-excursion |
251 (if (eq (marker-buffer | 251 (mapcar (lambda (buffer) |
252 (car (cdr (car errors)))) | 252 (set-buffer buffer) |
253 buffer) | 253 (let ((errors (or |
254 (setq buffer-error-marked-p t)) | 254 compilation-old-error-list |
255 (setq errors (cdr errors))) | 255 compilation-error-list)) |
256 buffer-error-marked-p))) | 256 (buffer-error-marked-p nil)) |
257 ;; Make the right thing happen in transient-mark-mode. | 257 (while (and errors |
258 (mark-active nil)) | 258 (not buffer-error-marked-p)) |
259 (if (eq buffer | |
260 (marker-buffer | |
261 (car (cdr (car errors))))) | |
262 (setq buffer-error-marked-p t)) | |
263 (setq errors (cdr errors))) | |
264 (if buffer-error-marked-p buffer))) | |
265 (buffer-list))))))) | |
259 | 266 |
260 ;; the actual revisit | 267 ;; the actual revisit |
261 (revert-buffer arg no-confirm) | 268 (revert-buffer arg no-confirm) |
262 | 269 |
263 ;; Reparse remaining *compilation* errors, if necessary: | 270 ;; Reparse affected compilation buffers. |
264 (if reparse ; see next-error (compile.el) | 271 (while reparse |
265 (save-excursion | 272 (if (car reparse) |
266 (set-buffer "*compilation*") | 273 (save-excursion |
267 (set-buffer-modified-p nil) ; ? | 274 (set-buffer (car reparse)) |
268 (if (consp compilation-error-list) ; not t, nor () | 275 (let ((compilation-last-buffer (current-buffer)) ;select buffer |
269 (setq compilation-parsing-end | 276 ;; Record the position in the compilation buffer of |
270 (marker-position | 277 ;; the last error next-error went to. |
271 (car (car compilation-error-list))))) | 278 (error-pos (marker-position |
272 (compilation-forget-errors) | 279 (car (car-safe compilation-error-list))))) |
273 (compilation-parse-errors))) | 280 ;; Reparse the error messages as far as they were parsed before. |
281 (compile-reinitialize-errors '(4) compilation-parsing-end) | |
282 ;; Move the pointer up to find the error we were at before | |
283 ;; reparsing. Now next-error should properly go to the next one. | |
284 (while (and compilation-error-list | |
285 (/= error-pos (car (car errors)))) | |
286 (setq compilation-error-list (cdr compilation-error-list)))))) | |
287 (setq reparse (cdr reparse))) | |
274 | 288 |
275 ;; Restore point and mark | 289 ;; Restore point and mark |
276 (let ((new-point (vc-find-position-by-context point-context))) | 290 (let ((new-point (vc-find-position-by-context point-context))) |
277 (if new-point (goto-char new-point))) | 291 (if new-point (goto-char new-point))) |
278 (if mark-context | 292 (if mark-context |