aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath1995-06-14 15:47:10 +0000
committerRoland McGrath1995-06-14 15:47:10 +0000
commitcd494de4978c67d6ef37713ef6e26e482799df42 (patch)
tree1609013077ecb7d21e2284098aec2a547d870031
parent4b619ecad71d9701cc2b54edf781e48573cadf8f (diff)
downloademacs-cd494de4978c67d6ef37713ef6e26e482799df42.tar.gz
emacs-cd494de4978c67d6ef37713ef6e26e482799df42.zip
(compilation-find-file): If FILENAME is absolute, apply
abbreviate-file-name to it and then use its directory part as the first search path element, searching for its nondirectory part. Fix prompting code not to use a free variable. (compilation-parse-errors, compile-abbreviate-directory): Use abbreviate-file-name on directories.
-rw-r--r--lisp/progmodes/compile.el62
1 files changed, 39 insertions, 23 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 6e16be1f002..2d8bc6acd6c 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1095,35 +1095,42 @@ Selects a window with point at SOURCE, with another window displaying ERROR."
1095(defun compilation-find-file (marker filename dir &rest formats) 1095(defun compilation-find-file (marker filename dir &rest formats)
1096 (or formats (setq formats '("%s"))) 1096 (or formats (setq formats '("%s")))
1097 (let ((dirs compilation-search-path) 1097 (let ((dirs compilation-search-path)
1098 result thisdir fmts name) 1098 buffer thisdir fmts name)
1099 (while (and dirs (null result)) 1099 (if (file-name-absolute-p filename)
1100 ;; The file name is absolute. Use its explicit directory as
1101 ;; the first in the search path, and strip it from FILENAME.
1102 (setq filename (abbreviate-file-name (expand-file-name filename))
1103 dirs (cons (file-name-directory filename) dirs)
1104 filename (file-name-nondirectory filename)))
1105 ;; Now search the path.
1106 (while (and dirs (null buffer))
1100 (setq thisdir (or (car dirs) dir) 1107 (setq thisdir (or (car dirs) dir)
1101 fmts formats) 1108 fmts formats)
1102 (while (and fmts (null result)) 1109 ;; For each directory, try each format string.
1110 (while (and fmts (null buffer))
1103 (setq name (expand-file-name (format (car fmts) filename) thisdir) 1111 (setq name (expand-file-name (format (car fmts) filename) thisdir)
1104 result (and (file-exists-p name) 1112 buffer (and (file-exists-p name)
1105 (find-file-noselect name)) 1113 (find-file-noselect name))
1106 fmts (cdr fmts))) 1114 fmts (cdr fmts)))
1107 (setq dirs (cdr dirs))) 1115 (setq dirs (cdr dirs)))
1108 (or result 1116 (or buffer
1109 ;; The file doesn't exist. 1117 ;; The file doesn't exist.
1110 ;; Ask the user where to find it. 1118 ;; Ask the user where to find it.
1111 ;; If he hits C-g, then the next time he does 1119 ;; If he hits C-g, then the next time he does
1112 ;; next-error, he'll skip past it. 1120 ;; next-error, he'll skip past it.
1113 (progn 1121 (let* ((pop-up-windows t)
1114 (let* ((pop-up-windows t) 1122 (w (display-buffer (marker-buffer marker))))
1115 (w (display-buffer (marker-buffer marker)))) 1123 (set-window-point w marker)
1116 (set-window-point w marker) 1124 (set-window-start w marker)
1117 (set-window-start w marker)) 1125 (let ((name (expand-file-name
1118 (setq name 1126 (read-file-name
1119 (expand-file-name 1127 (format "Find this error in: (default %s) "
1120 (read-file-name (format "Find this error in: (default %s) " 1128 filename)
1121 filename) 1129 dir filename t))))
1122 dir filename t))) 1130 (if (file-directory-p name)
1123 (if (file-directory-p name) 1131 (setq name (expand-file-name filename name)))
1124 (setq name (concat (file-name-as-directory name) filename))) 1132 (and (file-exists-p name)
1125 (if (file-exists-p name) 1133 (find-file-noselect name)))))))
1126 (find-file-noselect name))))))
1127 1134
1128;; Set compilation-error-list to nil, and unchain the markers that point to the 1135;; Set compilation-error-list to nil, and unchain the markers that point to the
1129;; error messages and their text, so that they no longer slow down gap motion. 1136;; error messages and their text, so that they no longer slow down gap motion.
@@ -1230,9 +1237,14 @@ See variable `compilation-parse-errors-function' for the interface it uses."
1230 (setq subexpr (+ subexpr 1 (count-regexp-groupings (car (car alist))))) 1237 (setq subexpr (+ subexpr 1 (count-regexp-groupings (car (car alist)))))
1231 (setq alist (cdr alist))) 1238 (setq alist (cdr alist)))
1232 1239
1233 (setq orig default-directory) 1240 ;; Set up now the expanded, abbreviated directory variables
1234 (setq orig-expanded (file-truename orig)) 1241 ;; that compile-abbreviate-directory will need, so we can
1235 (setq parent-expanded (expand-file-name "../" orig-expanded)) 1242 ;; compute them just once here.
1243 (setq orig (abbreviate-file-name default-directory)
1244 orig-expanded (abbreviate-file-name
1245 (file-truename default-directory))
1246 parent-expanded (abbreviate-file-name
1247 (expand-file-name "../" orig-expanded)))
1236 1248
1237 (while (and (not found-desired) 1249 (while (and (not found-desired)
1238 ;; We don't just pass LIMIT-SEARCH to re-search-forward 1250 ;; We don't just pass LIMIT-SEARCH to re-search-forward
@@ -1279,7 +1291,7 @@ See variable `compilation-parse-errors-function' for the interface it uses."
1279 (buffer-substring beg 1291 (buffer-substring beg
1280 (match-end (+ leave-group 1292 (match-end (+ leave-group
1281 1))))))) 1293 1)))))))
1282 ;; The directory name in the "entering" message 1294 ;; The directory name in the "leaving" message
1283 ;; is a truename. Try to convert it to a form 1295 ;; is a truename. Try to convert it to a form
1284 ;; like what the user typed in. 1296 ;; like what the user typed in.
1285 (setq dir 1297 (setq dir
@@ -1412,6 +1424,10 @@ See variable `compilation-parse-errors-function' for the interface it uses."
1412;; Those two args could be computed here, but we run faster by 1424;; Those two args could be computed here, but we run faster by
1413;; having the caller compute them just once. 1425;; having the caller compute them just once.
1414(defun compile-abbreviate-directory (dir orig orig-expanded parent-expanded) 1426(defun compile-abbreviate-directory (dir orig orig-expanded parent-expanded)
1427 ;; Apply canonical abbreviations to DIR first thing.
1428 ;; Those abbreviations are already done in the other arguments passed.
1429 (setq dir (abbreviate-file-name dir))
1430
1415 ;; Check for a comint-file-name-prefix and prepend it if appropriate. 1431 ;; Check for a comint-file-name-prefix and prepend it if appropriate.
1416 ;; (This is very useful for compilation-minor-mode in an rlogin-mode 1432 ;; (This is very useful for compilation-minor-mode in an rlogin-mode
1417 ;; buffer.) 1433 ;; buffer.)