aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath1994-01-06 15:25:19 +0000
committerRoland McGrath1994-01-06 15:25:19 +0000
commit51ba27e7aca87365152d38cbb18be3572b025d53 (patch)
tree9e1004aeb772b026c8f92a44198b915913691c53
parent52d7b2e563b6ea86405963dedf2ba2236d0f6c58 (diff)
downloademacs-51ba27e7aca87365152d38cbb18be3572b025d53.tar.gz
emacs-51ba27e7aca87365152d38cbb18be3572b025d53.zip
(compilation-buffer-p): Move defsubst before all callers.
(compilation-forget-errors): Reset compilation-parsing-end to 1 here. (compile-reinitialize-errors): Don't reset compilation-parsing-end after calling compilation-forget-errors. Comment out gratuitous switch-to-buffer call; what was the rationale for it? Don't check compilation-parsing-end (removed local AT-START); instead always append to compilation-old-error-list, it will be nil if at start. If compilation-error-list is non-nil before calling the parser, restore its previous value afterwards; it still indicates the current error position. Subtract the length of the existing compilation-error-list from FIND-AT-LEAST when calling the parser. (compilation-parse-errors): Don't check LIMIT-SEARCH at end of loop. Inside check it inside each case of the cond; in error case we must discard the last new error before stopping (just as for FIND-AT-LEAST). Use floating-point in buffer percentage calculation, to avoid integer overflow.
-rw-r--r--lisp/progmodes/compile.el94
1 files changed, 65 insertions, 29 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 9598c10914a..5da647185fe 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1,6 +1,6 @@
1;;; compile.el --- run compiler as inferior of Emacs, parse error messages. 1;;; compile.el --- run compiler as inferior of Emacs, parse error messages.
2 2
3;; Copyright (C) 1985, 86, 87, 93 Free Software Foundation, Inc. 3;; Copyright (C) 1985, 86, 87, 93, 94 Free Software Foundation, Inc.
4 4
5;; Author: Roland McGrath <roland@prep.ai.mit.edu> 5;; Author: Roland McGrath <roland@prep.ai.mit.edu>
6;; Maintainer: FSF 6;; Maintainer: FSF
@@ -500,6 +500,9 @@ Just inserts the text, but uses `insert-before-markers'."
500 (setq errors (cdr errors))) 500 (setq errors (cdr errors)))
501 errors)) 501 errors))
502 502
503(defsubst compilation-buffer-p (buffer)
504 (assq 'compilation-error-list (buffer-local-variables buffer)))
505
503(defun compilation-next-error (n) 506(defun compilation-next-error (n)
504 "Move point to the next error in the compilation buffer. 507 "Move point to the next error in the compilation buffer.
505Does NOT find the source line like \\[next-error]." 508Does NOT find the source line like \\[next-error]."
@@ -631,8 +634,7 @@ Does NOT find the source line like \\[next-error]."
631 ;; discard the info we have, to force reparsing. 634 ;; discard the info we have, to force reparsing.
632 (if (or (eq compilation-error-list t) 635 (if (or (eq compilation-error-list t)
633 (consp argp)) 636 (consp argp))
634 (progn (compilation-forget-errors) 637 (compilation-forget-errors))
635 (setq compilation-parsing-end 1)))
636 (if (and compilation-error-list 638 (if (and compilation-error-list
637 (or (not limit-search) 639 (or (not limit-search)
638 (> compilation-parsing-end limit-search)) 640 (> compilation-parsing-end limit-search))
@@ -641,18 +643,32 @@ Does NOT find the source line like \\[next-error]."
641 ;; Since compilation-error-list is non-nil, it points to a specific 643 ;; Since compilation-error-list is non-nil, it points to a specific
642 ;; error the user wanted. So don't move it around. 644 ;; error the user wanted. So don't move it around.
643 nil 645 nil
644 (switch-to-buffer compilation-last-buffer) 646 ;; This was here for a long time (before my rewrite); why? --roland
647 ;;(switch-to-buffer compilation-last-buffer)
645 (set-buffer-modified-p nil) 648 (set-buffer-modified-p nil)
646 (if (< compilation-parsing-end (point-max)) 649 (if (< compilation-parsing-end (point-max))
647 (let ((at-start (= compilation-parsing-end 1))) 650 ;; compilation-error-list might be non-nil if we have a non-nil
651 ;; LIMIT-SEARCH of FIND-AT-LEAST arg. In that case its value
652 ;; records the current position in the error list, and we must
653 ;; preserve that after reparsing.
654 (let ((error-list-pos compilation-error-list))
648 (funcall compilation-parse-errors-function 655 (funcall compilation-parse-errors-function
649 limit-search find-at-least) 656 limit-search
650 ;; Remember the entire list for compilation-forget-errors. 657 (and find-at-least
651 ;; If this is an incremental parse, append to previous list. 658 ;; We only need enough new parsed errors to reach
652 (if at-start 659 ;; FIND-AT-LEAST errors past the current
653 (setq compilation-old-error-list compilation-error-list) 660 ;; position.
654 (setq compilation-old-error-list 661 (- find-at-least (length compilation-error-list))))
655 (nconc compilation-old-error-list compilation-error-list))) 662 ;; Remember the entire list for compilation-forget-errors. If
663 ;; this is an incremental parse, append to previous list. If
664 ;; we are parsing anew, compilation-forget-errors cleared
665 ;; compilation-old-error-list above.
666 (setq compilation-old-error-list
667 (nconc compilation-old-error-list compilation-error-list))
668 (if error-list-pos
669 ;; We started in the middle of an existing list of parsed
670 ;; errors before parsing more; restore that position.
671 (setq compilation-error-list error-list-pos))
656 ))))) 672 )))))
657 673
658(defun compile-goto-error (&optional argp) 674(defun compile-goto-error (&optional argp)
@@ -687,9 +703,6 @@ other kinds of prefix arguments are ignored."
687 703
688 (next-error 1)) 704 (next-error 1))
689 705
690(defsubst compilation-buffer-p (buffer)
691 (assq 'compilation-error-list (buffer-local-variables buffer)))
692
693;; Return a compilation buffer. 706;; Return a compilation buffer.
694;; If the current buffer is a compilation buffer, return it. 707;; If the current buffer is a compilation buffer, return it.
695;; If compilation-last-buffer is set to a live buffer, use that. 708;; If compilation-last-buffer is set to a live buffer, use that.
@@ -926,7 +939,8 @@ See variables `compilation-parse-errors-function' and
926 (set-marker (cdr next-error) nil))) 939 (set-marker (cdr next-error) nil)))
927 (setq compilation-old-error-list (cdr compilation-old-error-list))) 940 (setq compilation-old-error-list (cdr compilation-old-error-list)))
928 (setq compilation-error-list nil 941 (setq compilation-error-list nil
929 compilation-directory-stack nil)) 942 compilation-directory-stack nil
943 compilation-parsing-end 1))
930 944
931 945
932(defun count-regexp-groupings (regexp) 946(defun count-regexp-groupings (regexp)
@@ -1041,8 +1055,17 @@ See variable `compilation-parse-errors-function' for the interface it uses."
1041 (setq compilation-directory-stack 1055 (setq compilation-directory-stack
1042 (cons dir compilation-directory-stack)) 1056 (cons dir compilation-directory-stack))
1043 (and (file-directory-p dir) 1057 (and (file-directory-p dir)
1044 (setq default-directory dir)))) 1058 (setq default-directory dir)))
1045 1059
1060 (and limit-search (>= (point) limit-search)
1061 ;; The user wanted a specific error, and we're past it.
1062 ;; We do this check here (and in the leave-group case)
1063 ;; rather than at the end of the loop because if the last
1064 ;; thing seen is an error message, we must carefully
1065 ;; discard the last error when it is the first in a new
1066 ;; file (see below in the error-group case).
1067 (setq found-desired t)))
1068
1046 ((match-beginning leave-group) 1069 ((match-beginning leave-group)
1047 ;; The match was the leave-directory regexp. 1070 ;; The match was the leave-directory regexp.
1048 (let ((beg (match-beginning (+ leave-group 1))) 1071 (let ((beg (match-beginning (+ leave-group 1)))
@@ -1067,8 +1090,17 @@ See variable `compilation-parse-errors-function' for the interface it uses."
1067 (setq stack (car compilation-directory-stack)) 1090 (setq stack (car compilation-directory-stack))
1068 (if stack 1091 (if stack
1069 (setq default-directory stack)) 1092 (setq default-directory stack))
1070 )) 1093 )
1071 1094
1095 (and limit-search (>= (point) limit-search)
1096 ;; The user wanted a specific error, and we're past it.
1097 ;; We do this check here (and in the enter-group case)
1098 ;; rather than at the end of the loop because if the last
1099 ;; thing seen is an error message, we must carefully
1100 ;; discard the last error when it is the first in a new
1101 ;; file (see below in the error-group case).
1102 (setq found-desired t)))
1103
1072 ((match-beginning error-group) 1104 ((match-beginning error-group)
1073 ;; The match was the composite error regexp. 1105 ;; The match was the composite error regexp.
1074 ;; Find out which individual regexp matched. 1106 ;; Find out which individual regexp matched.
@@ -1109,13 +1141,15 @@ See variable `compilation-parse-errors-function' for the interface it uses."
1109 compilation-error-list)) 1141 compilation-error-list))
1110 (setq compilation-num-errors-found 1142 (setq compilation-num-errors-found
1111 (1+ compilation-num-errors-found))))) 1143 (1+ compilation-num-errors-found)))))
1112 (and find-at-least (>= compilation-num-errors-found 1144 (and (or (and find-at-least (> compilation-num-errors-found
1113 find-at-least) 1145 find-at-least))
1114 ;; We have found as many new errors as the user wants. 1146 (and limit-search (>= (point) limit-search)))
1115 ;; We continue to parse until we have seen all 1147 ;; We have found as many new errors as the user wants,
1116 ;; the consecutive errors in the same file, 1148 ;; or past the buffer position he indicated. We
1117 ;; so the error positions will be recorded as markers 1149 ;; continue to parse until we have seen all the
1118 ;; in this buffer that might change. 1150 ;; consecutive errors in the same file, so the error
1151 ;; positions will be recorded as markers in this buffer
1152 ;; that might change.
1119 (cdr compilation-error-list) ; Must check at least two. 1153 (cdr compilation-error-list) ; Must check at least two.
1120 (not (equal (car (cdr (nth 0 compilation-error-list))) 1154 (not (equal (car (cdr (nth 0 compilation-error-list)))
1121 (car (cdr (nth 1 compilation-error-list))))) 1155 (car (cdr (nth 1 compilation-error-list)))))
@@ -1134,9 +1168,11 @@ See variable `compilation-parse-errors-function' for the interface it uses."
1134 (t 1168 (t
1135 (error "compilation-parse-errors: known groups didn't match!"))) 1169 (error "compilation-parse-errors: known groups didn't match!")))
1136 1170
1137 (message "Parsing error messages...%d (%d%% of buffer)" 1171 (message "Parsing error messages...%d (%.0f%% of buffer)"
1138 compilation-num-errors-found 1172 compilation-num-errors-found
1139 (/ (* 100 (point)) (point-max))) 1173 ;; Use floating-point because (* 100 (point)) frequently
1174 ;; exceeds the range of Emacs Lisp integers.
1175 (/ (* 100.0 (point)) (point-max)))
1140 1176
1141 (and limit-search (>= (point) limit-search) 1177 (and limit-search (>= (point) limit-search)
1142 ;; The user wanted a specific error, and we're past it. 1178 ;; The user wanted a specific error, and we're past it.