diff options
| author | Roland McGrath | 1992-08-04 02:02:27 +0000 |
|---|---|---|
| committer | Roland McGrath | 1992-08-04 02:02:27 +0000 |
| commit | b5bb472ebef87cbf33931c671436738ea102f6b0 (patch) | |
| tree | e3a506c21ce20decf0c48d19f5a45c63f6eb14bd | |
| parent | e17d2fd17924c106f91b1cbc8d0a38561e7f00ad (diff) | |
| download | emacs-b5bb472ebef87cbf33931c671436738ea102f6b0.tar.gz emacs-b5bb472ebef87cbf33931c671436738ea102f6b0.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/progmodes/compile.el | 164 |
1 files changed, 109 insertions, 55 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 477cca1bddb..f46cd7bd0b2 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el | |||
| @@ -310,6 +310,8 @@ Returns the compilation buffer created." | |||
| 310 | (define-key map "\^?" 'scroll-down) | 310 | (define-key map "\^?" 'scroll-down) |
| 311 | (define-key map "\M-n" 'compilation-next-error) | 311 | (define-key map "\M-n" 'compilation-next-error) |
| 312 | (define-key map "\M-p" 'compilation-previous-error) | 312 | (define-key map "\M-p" 'compilation-previous-error) |
| 313 | (define-key map "\C-x[" 'compilation-previous-file) | ||
| 314 | (define-key map "\C-x]" 'compilation-next-file) | ||
| 313 | map) | 315 | map) |
| 314 | "Keymap for compilation log buffers.") | 316 | "Keymap for compilation log buffers.") |
| 315 | 317 | ||
| @@ -382,6 +384,15 @@ Runs `compilation-mode-hook' with `run-hooks' (which see)." | |||
| 382 | )))) | 384 | )))) |
| 383 | 385 | ||
| 384 | 386 | ||
| 387 | ;; Return the cdr of compilation-old-error-list for the error containing point. | ||
| 388 | (defun compile-error-at-point () | ||
| 389 | (compile-reinitialize-errors nil (point)) | ||
| 390 | (let ((errors compilation-old-error-list)) | ||
| 391 | (while (and errors | ||
| 392 | (> (point) (car (car errors)))) | ||
| 393 | (setq errors (cdr errors))) | ||
| 394 | errors)) | ||
| 395 | |||
| 385 | (defun compilation-next-error (n) | 396 | (defun compilation-next-error (n) |
| 386 | "Move point to the next error in the compilation buffer. | 397 | "Move point to the next error in the compilation buffer. |
| 387 | Does NOT find the source line like \\[next-error]." | 398 | Does NOT find the source line like \\[next-error]." |
| @@ -389,51 +400,25 @@ Does NOT find the source line like \\[next-error]." | |||
| 389 | (or (compilation-buffer-p (current-buffer)) | 400 | (or (compilation-buffer-p (current-buffer)) |
| 390 | (error "Not in a compilation buffer.")) | 401 | (error "Not in a compilation buffer.")) |
| 391 | (setq compilation-last-buffer (current-buffer)) | 402 | (setq compilation-last-buffer (current-buffer)) |
| 392 | (let ((p (point)) | 403 | |
| 393 | (errors nil) | 404 | (let ((errors (compile-error-at-point))) |
| 394 | (first t)) | 405 | |
| 395 | 406 | ;; Move to the error after the one containing point. | |
| 396 | (save-excursion ;save point in case of later error | 407 | (goto-char (car (if (< n 0) |
| 397 | (while (and (if (< n 0) | 408 | (let ((i 0) |
| 398 | (null errors) | 409 | (e compilation-old-error-list)) |
| 399 | (< (length errors) n)) | 410 | ;; See how many cdrs away ERRORS is from the start. |
| 400 | (or first (< compilation-parsing-end (point-max)))) | 411 | (while (not (eq e errors)) |
| 401 | (setq first nil) | 412 | (setq i (1+ i) |
| 402 | 413 | e (cdr e))) | |
| 403 | (if (< compilation-parsing-end (point-max)) | 414 | (if (> (- n) i) |
| 404 | (progn | 415 | (error "Moved back past first error") |
| 405 | ;; Move forward a bit and parse. | 416 | (nth (+ i n) compilation-old-error-list))) |
| 406 | ;; Hopefully we will parse enough to find the one we want. | 417 | (let ((compilation-error-list (cdr errors))) |
| 407 | (forward-line n) | 418 | (compile-reinitialize-errors nil nil n) |
| 408 | (compile-reinitialize-errors nil (point)))) | 419 | (if compilation-error-list |
| 409 | (setq errors compilation-old-error-list) | 420 | (nth (1- n) compilation-error-list) |
| 410 | 421 | (error "Moved past last error")))))))) | |
| 411 | ;; Look for the error containing P (the original point). | ||
| 412 | (if (< n 0) | ||
| 413 | (while (and errors | ||
| 414 | (> p (car (car errors)))) | ||
| 415 | (setq errors (cdr errors))) | ||
| 416 | (while (and errors | ||
| 417 | (>= p (car (car errors)))) | ||
| 418 | (setq errors (cdr errors)))) | ||
| 419 | (ignore)) | ||
| 420 | |||
| 421 | ;; Move to the error after the one containing point. | ||
| 422 | (setq p (car (if (< n 0) | ||
| 423 | (let ((i 0) | ||
| 424 | (e compilation-old-error-list)) | ||
| 425 | ;; See how many cdrs away ERRORS is from the start. | ||
| 426 | (while (not (eq e errors)) | ||
| 427 | (setq i (1+ i) | ||
| 428 | e (cdr e))) | ||
| 429 | (if (> (- n) i) | ||
| 430 | (error "Moved back past first error") | ||
| 431 | (nth (+ i n) compilation-old-error-list))) | ||
| 432 | (if errors | ||
| 433 | (nth (1- n) errors) | ||
| 434 | (error "Moved past last error")))))) | ||
| 435 | |||
| 436 | (goto-char p))) | ||
| 437 | 422 | ||
| 438 | (defun compilation-previous-error (n) | 423 | (defun compilation-previous-error (n) |
| 439 | "Move point to the previous error in the compilation buffer. | 424 | "Move point to the previous error in the compilation buffer. |
| @@ -442,6 +427,71 @@ Does NOT find the source line like \\[next-error]." | |||
| 442 | (compilation-next-error (- n))) | 427 | (compilation-next-error (- n))) |
| 443 | 428 | ||
| 444 | 429 | ||
| 430 | (defun compile-file-of-error (data) | ||
| 431 | (setq data (cdr data)) | ||
| 432 | (if (markerp data) | ||
| 433 | (buffer-file-name (marker-buffer data)) | ||
| 434 | (setq data (car data)) | ||
| 435 | (expand-file-name (cdr data) (car data)))) | ||
| 436 | |||
| 437 | (defun compilation-next-file (n) | ||
| 438 | "Move point to the next error for a different file than the current one." | ||
| 439 | (interactive "p") | ||
| 440 | (or (compilation-buffer-p (current-buffer)) | ||
| 441 | (error "Not in a compilation buffer.")) | ||
| 442 | (setq compilation-last-buffer (current-buffer)) | ||
| 443 | |||
| 444 | (let ((reversed (< n 0)) | ||
| 445 | errors file) | ||
| 446 | |||
| 447 | (if (not reversed) | ||
| 448 | (setq errors (or (compile-error-at-point) | ||
| 449 | (error "Moved past last error"))) | ||
| 450 | |||
| 451 | ;; Get a reversed list of the errors up through the one containing point. | ||
| 452 | (compile-reinitialize-errors nil (point)) | ||
| 453 | (setq errors (reverse compilation-old-error-list) | ||
| 454 | n (- n)) | ||
| 455 | |||
| 456 | ;; Ignore errors after point. (car ERRORS) will be the error | ||
| 457 | ;; containing point, (cadr ERRORS) the one before it. | ||
| 458 | (while (and errors | ||
| 459 | (< (point) (car (car errors)))) | ||
| 460 | (setq errors (cdr errors)))) | ||
| 461 | |||
| 462 | (while (> n 0) | ||
| 463 | (setq file (compile-file-of-error (car errors))) | ||
| 464 | |||
| 465 | ;; Skip past the other errors for this file. | ||
| 466 | (while (string= file | ||
| 467 | (compile-file-of-error | ||
| 468 | (car (or errors | ||
| 469 | (if reversed | ||
| 470 | (error "This is the first erring file") | ||
| 471 | (let ((compilation-error-list nil)) | ||
| 472 | ;; Parse some more. | ||
| 473 | (compile-reinitialize-errors nil nil 2) | ||
| 474 | (setq errors compilation-error-list))) | ||
| 475 | (error "This is the last erring file"))))) | ||
| 476 | (setq errors (cdr errors))) | ||
| 477 | |||
| 478 | (setq n (1- n))) | ||
| 479 | |||
| 480 | ;; Move to the following error. | ||
| 481 | (goto-char (car (car (or errors | ||
| 482 | (if reversed | ||
| 483 | (error "This is the first erring file") | ||
| 484 | (let ((compilation-error-list nil)) | ||
| 485 | ;; Parse the last one. | ||
| 486 | (compile-reinitialize-errors nil nil 1) | ||
| 487 | compilation-error-list)))))))) | ||
| 488 | |||
| 489 | (defun compilation-previous-file (n) | ||
| 490 | "Move point to the previous error for a different file than the current one." | ||
| 491 | (interactive "p") | ||
| 492 | (compilation-next-file (- n))) | ||
| 493 | |||
| 494 | |||
| 445 | (defun kill-compilation () | 495 | (defun kill-compilation () |
| 446 | "Kill the process made by the \\[compile] command." | 496 | "Kill the process made by the \\[compile] command." |
| 447 | (interactive) | 497 | (interactive) |
| @@ -463,7 +513,8 @@ Does NOT find the source line like \\[next-error]." | |||
| 463 | (progn (compilation-forget-errors) | 513 | (progn (compilation-forget-errors) |
| 464 | (setq compilation-parsing-end 1))) | 514 | (setq compilation-parsing-end 1))) |
| 465 | (if (and compilation-error-list | 515 | (if (and compilation-error-list |
| 466 | (not limit-search) | 516 | (or (not limit-search) |
| 517 | (> compilation-parsing-end limit-search)) | ||
| 467 | (or (not find-at-least) | 518 | (or (not find-at-least) |
| 468 | (> (length compilation-error-list) find-at-least))) | 519 | (> (length compilation-error-list) find-at-least))) |
| 469 | ;; Since compilation-error-list is non-nil, it points to a specific | 520 | ;; Since compilation-error-list is non-nil, it points to a specific |
| @@ -471,14 +522,17 @@ Does NOT find the source line like \\[next-error]." | |||
| 471 | nil | 522 | nil |
| 472 | (switch-to-buffer compilation-last-buffer) | 523 | (switch-to-buffer compilation-last-buffer) |
| 473 | (set-buffer-modified-p nil) | 524 | (set-buffer-modified-p nil) |
| 474 | (let ((at-start (= compilation-parsing-end 1))) | 525 | (if (< compilation-parsing-end (point-max)) |
| 475 | (funcall compilation-parse-errors-function limit-search find-at-least) | 526 | (let ((at-start (= compilation-parsing-end 1))) |
| 476 | ;; Remember the entire list for compilation-forget-errors. | 527 | (funcall compilation-parse-errors-function |
| 477 | ;; If this is an incremental parse, append to previous list. | 528 | limit-search find-at-least) |
| 478 | (if at-start | 529 | ;; Remember the entire list for compilation-forget-errors. |
| 479 | (setq compilation-old-error-list compilation-error-list) | 530 | ;; If this is an incremental parse, append to previous list. |
| 480 | (setq compilation-old-error-list | 531 | (if at-start |
| 481 | (nconc compilation-old-error-list compilation-error-list))))))) | 532 | (setq compilation-old-error-list compilation-error-list) |
| 533 | (setq compilation-old-error-list | ||
| 534 | (nconc compilation-old-error-list compilation-error-list))) | ||
| 535 | ))))) | ||
| 482 | 536 | ||
| 483 | (defun compile-goto-error (&optional argp) | 537 | (defun compile-goto-error (&optional argp) |
| 484 | "Visit the source for the error message point is on. | 538 | "Visit the source for the error message point is on. |
| @@ -565,7 +619,7 @@ See variables `compilation-parse-errors-function' and | |||
| 565 | \`compilation-error-regexp-alist' for customization ideas." | 619 | \`compilation-error-regexp-alist' for customization ideas." |
| 566 | (interactive "P") | 620 | (interactive "P") |
| 567 | (setq compilation-last-buffer (compilation-find-buffer)) | 621 | (setq compilation-last-buffer (compilation-find-buffer)) |
| 568 | (compile-reinitialize-errors argp nil (prefix-numeric-value argp)) | 622 | (compile-reinitialize-errors argp nil (1- (prefix-numeric-value argp))) |
| 569 | ;; Make ARGP nil if the prefix arg was just C-u, | 623 | ;; Make ARGP nil if the prefix arg was just C-u, |
| 570 | ;; since that means to reparse the errors, which the | 624 | ;; since that means to reparse the errors, which the |
| 571 | ;; compile-reinitialize-errors call just did. | 625 | ;; compile-reinitialize-errors call just did. |