comparison lisp/progmodes/compile.el @ 10928:a008a9d8966a

(compilation-buffer-p): Fix braino in last change: switch to the buffer first. (compilation-error-regexp-alist): Doc fix: optional cdrs give string containing %s to produce the file name from the matched text. (compilation-find-file): Reorder args: MARKER first, then FILENAME, DIR, and new arg &rest FORMATS (as they appear in parsed the fileinfo lists). Try each of the FORMATS in each directory tried. (compilation-next-error-locus): Apply compilation-find-file to the FILEINFO list. (compilation-parse-errors): Instead of a cons (DIR . FILE), make a list (FILE DIR [FORMATS...]) using the 4th cdr of the matching elt of regexp-alist.
author Roland McGrath <roland@gnu.org>
date Mon, 06 Mar 1995 15:51:22 +0000
parents 076c2c2b4f06
children d67cbc284d24
comparison
equal deleted inserted replaced
10927:7d02d12082ff 10928:a008a9d8966a
182 ;; SGI Irix 5.2 compiler warnings 182 ;; SGI Irix 5.2 compiler warnings
183 ;; cfe: Warning 835: vpr_tiff.c, line 65: No prototype for the call to rint 183 ;; cfe: Warning 835: vpr_tiff.c, line 65: No prototype for the call to rint
184 ("ning [0-9]+: \\([^,\" \n\t]+\\)[,:] \\(line \\)?\\([0-9]+\\):" 1 3) 184 ("ning [0-9]+: \\([^,\" \n\t]+\\)[,:] \\(line \\)?\\([0-9]+\\):" 1 3)
185 ) 185 )
186 "Alist that specifies how to match errors in compiler output. 186 "Alist that specifies how to match errors in compiler output.
187 Each element has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX]). 187 Each elt has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX FILE-FORMAT...])
188 If REGEXP matches, the FILE-IDX'th subexpression gives the file name, and 188 If REGEXP matches, the FILE-IDX'th subexpression gives the file name, and
189 the LINE-IDX'th subexpression gives the line number. If COLUMN-IDX is 189 the LINE-IDX'th subexpression gives the line number. If COLUMN-IDX is
190 given, the COLUMN-IDX'th subexpression gives the column number on that line.") 190 given, the COLUMN-IDX'th subexpression gives the column number on that line.
191 If any FILE-FORMAT is given, each is a format string to produce a file name to
192 try; %s in the string is replaced by the text matching the FILE-IDX'th
193 subexpression.")
191 194
192 (defvar compilation-read-command t 195 (defvar compilation-read-command t
193 "If not nil, M-x compile reads the compilation command to use. 196 "If not nil, M-x compile reads the compilation command to use.
194 Otherwise, M-x compile just uses the value of `compile-command'.") 197 Otherwise, M-x compile just uses the value of `compile-command'.")
195 198
584 (> (point) (car (car errors)))) 587 (> (point) (car (car errors))))
585 (setq errors (cdr errors))) 588 (setq errors (cdr errors)))
586 errors)) 589 errors))
587 590
588 (defsubst compilation-buffer-p (buffer) 591 (defsubst compilation-buffer-p (buffer)
589 (or compilation-minor-mode (eq major-mode 'compilation-mode))) 592 (save-excursion
593 (set-buffer buffer)
594 (or compilation-minor-mode (eq major-mode 'compilation-mode))))
590 595
591 (defun compilation-next-error (n) 596 (defun compilation-next-error (n)
592 "Move point to the next error in the compilation buffer. 597 "Move point to the next error in the compilation buffer.
593 Does NOT find the source line like \\[next-error]." 598 Does NOT find the source line like \\[next-error]."
594 (interactive "p") 599 (interactive "p")
969 t 974 t
970 (or (markerp (cdr next-error)) 975 (or (markerp (cdr next-error))
971 ;; This error has a filename/lineno pair. 976 ;; This error has a filename/lineno pair.
972 ;; Find the file and turn it into a marker. 977 ;; Find the file and turn it into a marker.
973 (let* ((fileinfo (car (cdr next-error))) 978 (let* ((fileinfo (car (cdr next-error)))
974 (buffer (compilation-find-file (cdr fileinfo) 979 (buffer (apply 'compilation-find-file
975 (car fileinfo) 980 (car next-error) fileinfo)))
976 (car next-error))))
977 (if (null buffer) 981 (if (null buffer)
978 ;; We can't find this error's file. 982 ;; We can't find this error's file.
979 ;; Remove all errors in the same file. 983 ;; Remove all errors in the same file.
980 (progn 984 (progn
981 (setq next-errors compilation-old-error-list) 985 (setq next-errors compilation-old-error-list)
1076 ;; Search the directories in compilation-search-path. 1080 ;; Search the directories in compilation-search-path.
1077 ;; A nil in compilation-search-path means to try the 1081 ;; A nil in compilation-search-path means to try the
1078 ;; current directory, which is passed in DIR. 1082 ;; current directory, which is passed in DIR.
1079 ;; If FILENAME is not found at all, ask the user where to find it. 1083 ;; If FILENAME is not found at all, ask the user where to find it.
1080 ;; Pop up the buffer containing MARKER and scroll to MARKER if we ask the user. 1084 ;; Pop up the buffer containing MARKER and scroll to MARKER if we ask the user.
1081 (defun compilation-find-file (filename dir marker) 1085 (defun compilation-find-file (marker filename dir &rest formats)
1086 (or formats (setq formats '("%s")))
1082 (let ((dirs compilation-search-path) 1087 (let ((dirs compilation-search-path)
1083 result name) 1088 result thisdir fmts name)
1084 (while (and dirs (null result)) 1089 (while (and dirs (null result))
1085 (setq name (expand-file-name filename (or (car dirs) dir)) 1090 (setq thisdir (or (car dirs) dir)
1086 result (and (file-exists-p name) 1091 fmts formats)
1087 (find-file-noselect name)) 1092 (while (and fmts (null result))
1088 dirs (cdr dirs))) 1093 (setq name (expand-file-name (format (car fmts) filename) thisdir)
1094 result (and (file-exists-p name)
1095 (find-file-noselect name))
1096 fmts (cdr fmts)))
1097 (setq dirs (cdr dirs)))
1089 (or result 1098 (or result
1090 ;; The file doesn't exist. 1099 ;; The file doesn't exist.
1091 ;; Ask the user where to find it. 1100 ;; Ask the user where to find it.
1092 ;; If he hits C-g, then the next time he does 1101 ;; If he hits C-g, then the next time he does
1093 ;; next-error, he'll skip past it. 1102 ;; next-error, he'll skip past it.
1317 ;; If the file name is relative, default-directory will 1326 ;; If the file name is relative, default-directory will
1318 ;; already contain the comint-file-name-prefix (done by 1327 ;; already contain the comint-file-name-prefix (done by
1319 ;; compile-abbreviate-directory). 1328 ;; compile-abbreviate-directory).
1320 (file-name-absolute-p filename) 1329 (file-name-absolute-p filename)
1321 (setq filename (concat comint-file-name-prefix filename))) 1330 (setq filename (concat comint-file-name-prefix filename)))
1322 (setq filename (cons default-directory filename)) 1331 (setq filename (cons filename (cons default-directory
1332 (nthcdr 4 alist))))
1333
1323 1334
1324 ;; Locate the erring file and line. 1335 ;; Locate the erring file and line.
1325 ;; Cons a new elt onto compilation-error-list, 1336 ;; Cons a new elt onto compilation-error-list,
1326 ;; giving a marker for the current compilation buffer 1337 ;; giving a marker for the current compilation buffer
1327 ;; location, and the file and line number of the error. 1338 ;; location, and the file and line number of the error.