diff options
| -rw-r--r-- | lisp/progmodes/compile.el | 73 |
1 files changed, 41 insertions, 32 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index e13bec9f2df..ebff28bf7c3 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el | |||
| @@ -39,12 +39,12 @@ | |||
| 39 | 39 | ||
| 40 | (defvar compilation-error-list nil | 40 | (defvar compilation-error-list nil |
| 41 | "List of error message descriptors for visiting erring functions. | 41 | "List of error message descriptors for visiting erring functions. |
| 42 | Each error descriptor is a cons (or nil). Its car is a marker | 42 | Each error descriptor is a cons (or nil). Its car is a marker pointing to |
| 43 | pointing to an error message. If its cdr is a marker, it points to | 43 | an error message. If its cdr is a marker, it points to the text of the |
| 44 | the text of the line the message is about. If its cdr is a cons, that | 44 | line the message is about. If its cdr is a cons, that cons's car is a cons |
| 45 | cons's car is the name of the file the message is about, and its cdr | 45 | \(DIRECTORY . FILE\), specifying the file the message is about, and its cdr |
| 46 | is the number of the line the message is about. Or its cdr may be nil | 46 | is the number of the line the message is about. Or its cdr may be nil if |
| 47 | if that error is not interesting. | 47 | that error is not interesting. |
| 48 | 48 | ||
| 49 | The value may be t instead of a list; this means that the buffer of | 49 | The value may be t instead of a list; this means that the buffer of |
| 50 | error messages should be reparsed the next time the list of errors is wanted. | 50 | error messages should be reparsed the next time the list of errors is wanted. |
| @@ -507,12 +507,23 @@ Does NOT find the source line like \\[next-error]." | |||
| 507 | (compilation-next-error (- n))) | 507 | (compilation-next-error (- n))) |
| 508 | 508 | ||
| 509 | 509 | ||
| 510 | (defun compile-file-of-error (data) | 510 | ;; Given an elt of `compilation-error-list', return an object representing |
| 511 | ;; the referenced file which is equal to (but not necessarily eq to) what | ||
| 512 | ;; this function would return for another error in the same file. | ||
| 513 | (defsubst compilation-error-filedata (data) | ||
| 511 | (setq data (cdr data)) | 514 | (setq data (cdr data)) |
| 512 | (if (markerp data) | 515 | (if (markerp data) |
| 513 | (buffer-file-name (marker-buffer data)) | 516 | (marker-buffer data) |
| 514 | (car data))) | 517 | (car data))) |
| 515 | 518 | ||
| 519 | ;; Return a string describing a value from compilation-error-filedata. | ||
| 520 | ;; This value is not necessarily useful as a file name, but should be | ||
| 521 | ;; indicative to the user of what file's errors are being referred to. | ||
| 522 | (defsubst compilation-error-filedata-file-name (filedata) | ||
| 523 | (if (bufferp filedata) | ||
| 524 | (buffer-file-name filedata) | ||
| 525 | (car filedata))) | ||
| 526 | |||
| 516 | (defun compilation-next-file (n) | 527 | (defun compilation-next-file (n) |
| 517 | "Move point to the next error for a different file than the current one." | 528 | "Move point to the next error for a different file than the current one." |
| 518 | (interactive "p") | 529 | (interactive "p") |
| @@ -521,7 +532,7 @@ Does NOT find the source line like \\[next-error]." | |||
| 521 | (setq compilation-last-buffer (current-buffer)) | 532 | (setq compilation-last-buffer (current-buffer)) |
| 522 | 533 | ||
| 523 | (let ((reversed (< n 0)) | 534 | (let ((reversed (< n 0)) |
| 524 | errors file) | 535 | errors filedata) |
| 525 | 536 | ||
| 526 | (if (not reversed) | 537 | (if (not reversed) |
| 527 | (setq errors (or (compile-error-at-point) | 538 | (setq errors (or (compile-error-at-point) |
| @@ -539,19 +550,23 @@ Does NOT find the source line like \\[next-error]." | |||
| 539 | (setq errors (cdr errors)))) | 550 | (setq errors (cdr errors)))) |
| 540 | 551 | ||
| 541 | (while (> n 0) | 552 | (while (> n 0) |
| 542 | (setq file (compile-file-of-error (car errors))) | 553 | (setq filedata (compilation-error-filedata (car errors))) |
| 543 | 554 | ||
| 544 | ;; Skip past the other errors for this file. | 555 | ;; Skip past the following errors for this file. |
| 545 | (while (string= file | 556 | (while (equal filedata |
| 546 | (compile-file-of-error | 557 | (compilation-error-filedata |
| 547 | (car (or errors | 558 | (car (or errors |
| 548 | (if reversed | 559 | (if reversed |
| 549 | (error "%s the first erring file" file) | 560 | (error "%s the first erring file" |
| 550 | (let ((compilation-error-list nil)) | 561 | (compilation-error-filedata-file-name |
| 551 | ;; Parse some more. | 562 | filedata)) |
| 552 | (compile-reinitialize-errors nil nil 2) | 563 | (let ((compilation-error-list nil)) |
| 553 | (setq errors compilation-error-list))) | 564 | ;; Parse some more. |
| 554 | (error "%s is the last erring file" file))))) | 565 | (compile-reinitialize-errors nil nil 2) |
| 566 | (setq errors compilation-error-list))) | ||
| 567 | (error "%s is the last erring file" | ||
| 568 | (compilation-error-filedata-file-name | ||
| 569 | filedata)))))) | ||
| 555 | (setq errors (cdr errors))) | 570 | (setq errors (cdr errors))) |
| 556 | 571 | ||
| 557 | (setq n (1- n))) | 572 | (setq n (1- n))) |
| @@ -741,10 +756,7 @@ See variables `compilation-parse-errors-function' and | |||
| 741 | (or (markerp (cdr next-error)) | 756 | (or (markerp (cdr next-error)) |
| 742 | ;; This error has a filename/lineno pair. | 757 | ;; This error has a filename/lineno pair. |
| 743 | ;; Find the file and turn it into a marker. | 758 | ;; Find the file and turn it into a marker. |
| 744 | (let* ((fileinfo | 759 | (let* ((fileinfo (car (cdr next-error))) |
| 745 | (cons (file-name-directory (car (cdr next-error))) | ||
| 746 | (file-name-nondirectory | ||
| 747 | (car (cdr next-error))))) | ||
| 748 | (buffer (compilation-find-file (cdr fileinfo) | 760 | (buffer (compilation-find-file (cdr fileinfo) |
| 749 | (car fileinfo) | 761 | (car fileinfo) |
| 750 | (car next-error)))) | 762 | (car next-error)))) |
| @@ -1030,12 +1042,9 @@ See variable `compilation-parse-errors-function' for the interface it uses." | |||
| 1030 | ;; Extract the file name and line number from the error message. | 1042 | ;; Extract the file name and line number from the error message. |
| 1031 | (let ((beginning-of-match (match-beginning 0)) ;looking-at nukes | 1043 | (let ((beginning-of-match (match-beginning 0)) ;looking-at nukes |
| 1032 | (filename | 1044 | (filename |
| 1033 | (save-excursion | 1045 | (cons default-directory |
| 1034 | (goto-char (match-end (nth 1 alist))) | 1046 | (buffer-substring (match-beginning (nth 1 alist)) |
| 1035 | (skip-chars-backward " \t") | 1047 | (match-end (nth 1 alist))))) |
| 1036 | (let ((name (buffer-substring (match-beginning (nth 1 alist)) | ||
| 1037 | (point)))) | ||
| 1038 | (expand-file-name name default-directory)))) | ||
| 1039 | (linenum (save-restriction | 1048 | (linenum (save-restriction |
| 1040 | (narrow-to-region | 1049 | (narrow-to-region |
| 1041 | (match-beginning (nth 2 alist)) | 1050 | (match-beginning (nth 2 alist)) |