comparison lisp/progmodes/compile.el @ 4153:787df5416fba

(compilation-error-list): An elt's cdr's car is again a cons (DIRECTORY . FILE) if it's not a marker. The conversion to using a string containing an expanded file name was never finished, and anyway it utterly broke compilation-search-path and few other things. (next-error): Expect them that way. (compilation-parse-errors): Make them that way. (compile-file-of-error): Function removed. (compilation-error-filedata, compilation-error-filedata-file-name): New defsubsts. (compilation-next-file): Use them instead of compile-file-of-error.
author Roland McGrath <roland@gnu.org>
date Sun, 18 Jul 1993 20:41:08 +0000
parents d24725412d47
children 7ef7f31aab53
comparison
equal deleted inserted replaced
4152:1e1a395e4718 4153:787df5416fba
37 (defconst compilation-window-height nil 37 (defconst compilation-window-height nil
38 "*Number of lines in a compilation window. If nil, use Emacs default.") 38 "*Number of lines in a compilation window. If nil, use Emacs default.")
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.
51 51
52 Some other commands (like `diff') use this list to control the error 52 Some other commands (like `diff') use this list to control the error
505 Does NOT find the source line like \\[next-error]." 505 Does NOT find the source line like \\[next-error]."
506 (interactive "p") 506 (interactive "p")
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)))
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)))
515 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")
519 (or (compilation-buffer-p (current-buffer)) 530 (or (compilation-buffer-p (current-buffer))
520 (error "Not in a compilation buffer.")) 531 (error "Not in a compilation buffer."))
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)
528 (error "Moved past last error"))) 539 (error "Moved past last error")))
529 540
537 (while (and errors 548 (while (and errors
538 (< (point) (car (car errors)))) 549 (< (point) (car (car errors))))
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)))
558 573
559 ;; Move to the following error. 574 ;; Move to the following error.
739 ;; This error is boring. Go to the next. 754 ;; This error is boring. Go to the next.
740 t 755 t
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))))
751 (if (null buffer) 763 (if (null buffer)
752 ;; We can't find this error's file. 764 ;; We can't find this error's file.
1028 (error "compilation-parse-errors: impossible regexp match!")) 1040 (error "compilation-parse-errors: impossible regexp match!"))
1029 1041
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))
1042 (match-end (nth 2 alist))) 1051 (match-end (nth 2 alist)))
1043 (goto-char (point-min)) 1052 (goto-char (point-min))