aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-06-30 22:03:15 +0000
committerRichard M. Stallman1993-06-30 22:03:15 +0000
commit51501e543e37dd23c74321569ccf7ba9cc7c6de8 (patch)
treed068dd43b76650d8dbb183ee19156d45b4309bac
parent4b40fdea8fa54bdbe3824daeaa27dbacaae040a2 (diff)
downloademacs-51501e543e37dd23c74321569ccf7ba9cc7c6de8.tar.gz
emacs-51501e543e37dd23c74321569ccf7ba9cc7c6de8.zip
(compile-abbreviate-directory): New function.
(compilation-parse-errors): Use that, to visit files with a dirname more like the one the user specified.
-rw-r--r--lisp/progmodes/compile.el40
1 files changed, 39 insertions, 1 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 7bb2c95ff90..b20a8739de8 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -902,7 +902,7 @@ See variables `compilation-parse-errors-function' and
902See variable `compilation-parse-errors-function' for the interface it uses." 902See 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)
@@ -952,6 +952,10 @@ See variable `compilation-parse-errors-function' for the interface it uses."
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
@@ -966,6 +970,12 @@ See variable `compilation-parse-errors-function' for the interface it uses."
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)
@@ -982,6 +992,12 @@ See variable `compilation-parse-errors-function' for the interface it uses."
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)))))
@@ -1069,6 +1085,28 @@ See variable `compilation-parse-errors-function' for the interface it uses."
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