Mercurial > emacs
comparison lisp/progmodes/compile.el @ 3940:aa9f37730d77
(compile-abbreviate-directory): New function.
(compilation-parse-errors): Use that, to visit files with a dirname
more like the one the user specified.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 30 Jun 1993 22:03:15 +0000 |
parents | c5b6f641698a |
children | a37868b332ac |
comparison
equal
deleted
inserted
replaced
3939:1b954eb0f249 | 3940:aa9f37730d77 |
---|---|
900 (defun compilation-parse-errors (limit-search find-at-least) | 900 (defun compilation-parse-errors (limit-search find-at-least) |
901 "Parse the current buffer as grep, cc or lint error messages. | 901 "Parse the current buffer as grep, cc or lint error messages. |
902 See variable `compilation-parse-errors-function' for the interface it uses." | 902 See variable `compilation-parse-errors-function' for the interface it uses." |
903 (setq compilation-error-list nil) | 903 (setq compilation-error-list nil) |
904 (message "Parsing error messages...") | 904 (message "Parsing error messages...") |
905 (let (text-buffer | 905 (let (text-buffer orig orig-expanded parent-expanded |
906 regexp enter-group leave-group error-group | 906 regexp enter-group leave-group error-group |
907 alist subexpr error-regexp-groups | 907 alist subexpr error-regexp-groups |
908 (found-desired nil) | 908 (found-desired nil) |
909 (compilation-num-errors-found 0)) | 909 (compilation-num-errors-found 0)) |
910 | 910 |
950 (+ subexpr (nth 2 (car alist)))) | 950 (+ subexpr (nth 2 (car alist)))) |
951 error-regexp-groups)) | 951 error-regexp-groups)) |
952 (setq subexpr (+ subexpr 1 (count-regexp-groupings (car (car alist))))) | 952 (setq subexpr (+ subexpr 1 (count-regexp-groupings (car (car alist))))) |
953 (setq alist (cdr alist))) | 953 (setq alist (cdr alist))) |
954 | 954 |
955 (setq orig default-directory) | |
956 (setq orig-expanded (file-truename orig)) | |
957 (setq parent-expanded (expand-file-name "../" orig-expanded)) | |
958 | |
955 (while (and (not found-desired) | 959 (while (and (not found-desired) |
956 ;; We don't just pass LIMIT-SEARCH to re-search-forward | 960 ;; We don't just pass LIMIT-SEARCH to re-search-forward |
957 ;; because we want to find matches containing LIMIT-SEARCH | 961 ;; because we want to find matches containing LIMIT-SEARCH |
958 ;; but which extend past it. | 962 ;; but which extend past it. |
959 (re-search-forward regexp nil t)) | 963 (re-search-forward regexp nil t)) |
964 (let ((dir | 968 (let ((dir |
965 (file-name-as-directory | 969 (file-name-as-directory |
966 (expand-file-name | 970 (expand-file-name |
967 (buffer-substring (match-beginning (+ enter-group 1)) | 971 (buffer-substring (match-beginning (+ enter-group 1)) |
968 (match-end (+ enter-group 1))))))) | 972 (match-end (+ enter-group 1))))))) |
973 ;; The directory name in the "entering" message | |
974 ;; is a truename. Try to convert it to a form | |
975 ;; like what the user typed in. | |
976 (setq dir | |
977 (compile-abbreviate-directory dir orig orig-expanded | |
978 parent-expanded)) | |
969 (setq compilation-directory-stack | 979 (setq compilation-directory-stack |
970 (cons dir compilation-directory-stack)) | 980 (cons dir compilation-directory-stack)) |
971 (and (file-directory-p dir) | 981 (and (file-directory-p dir) |
972 (setq default-directory dir)))) | 982 (setq default-directory dir)))) |
973 | 983 |
980 (file-name-as-directory | 990 (file-name-as-directory |
981 (expand-file-name | 991 (expand-file-name |
982 (buffer-substring beg | 992 (buffer-substring beg |
983 (match-end (+ leave-group | 993 (match-end (+ leave-group |
984 1))))))) | 994 1))))))) |
995 ;; The directory name in the "entering" message | |
996 ;; is a truename. Try to convert it to a form | |
997 ;; like what the user typed in. | |
998 (setq dir | |
999 (compile-abbreviate-directory dir orig orig-expanded | |
1000 parent-expanded)) | |
985 (while (and stack | 1001 (while (and stack |
986 (not (string-equal (car stack) dir))) | 1002 (not (string-equal (car stack) dir))) |
987 (setq stack (cdr stack))))) | 1003 (setq stack (cdr stack))))) |
988 (setq compilation-directory-stack (cdr stack)) | 1004 (setq compilation-directory-stack (cdr stack)) |
989 (setq stack (car compilation-directory-stack)) | 1005 (setq stack (car compilation-directory-stack)) |
1067 ;; We have searched the whole buffer. | 1083 ;; We have searched the whole buffer. |
1068 (point-max)))) | 1084 (point-max)))) |
1069 (setq compilation-error-list (nreverse compilation-error-list)) | 1085 (setq compilation-error-list (nreverse compilation-error-list)) |
1070 (message "Parsing error messages...done")) | 1086 (message "Parsing error messages...done")) |
1071 | 1087 |
1088 ;; If directory DIR is a subdir of ORIG or of ORIG's parent, | |
1089 ;; return a relative name for it starting from ORIG or its parent. | |
1090 ;; ORIG-EXPANDED is an expanded version of ORIG. | |
1091 ;; PARENT-EXPANDED is an expanded version of ORIG's parent. | |
1092 ;; Those two args could be computed here, but we run faster by | |
1093 ;; having the caller compute them just once. | |
1094 (defun compile-abbreviate-directory (dir orig orig-expanded parent-expanded) | |
1095 (if (and (> (length dir) (length orig-expanded)) | |
1096 (string= orig-expanded | |
1097 (substring dir 0 (length orig-expanded)))) | |
1098 (setq dir | |
1099 (concat orig | |
1100 (substring dir (length orig-expanded))))) | |
1101 (if (and (> (length dir) (length parent-expanded)) | |
1102 (string= parent-expanded | |
1103 (substring dir 0 (length parent-expanded)))) | |
1104 (setq dir | |
1105 (concat (file-name-directory | |
1106 (directory-file-name orig)) | |
1107 (substring dir (length parent-expanded))))) | |
1108 dir) | |
1109 | |
1072 (provide 'compile) | 1110 (provide 'compile) |
1073 | 1111 |
1074 ;;; compile.el ends here | 1112 ;;; compile.el ends here |