comparison lisp/progmodes/compile.el @ 48197:caf0d482d3e3

(grep-compute-defaults): Move down.
author Markus Rost <rost@math.uni-bielefeld.de>
date Thu, 07 Nov 2002 17:16:09 +0000
parents d5e00837e437
children 1ee4b312fef0
comparison
equal deleted inserted replaced
48196:d5e00837e437 48197:caf0d482d3e3
64 :type '(choice (const :tag "All" t) 64 :type '(choice (const :tag "All" t)
65 (const :tag "None" nil) 65 (const :tag "None" nil)
66 (integer :tag "First N lines")) 66 (integer :tag "First N lines"))
67 :group 'compilation) 67 :group 'compilation)
68 68
69 ;;; This has to be here so it can be called 69 (defcustom grep-command nil
70 ;;; by the following defcustoms. 70 "The default grep command for \\[grep].
71 If the grep program used supports an option to always include file names
72 in its output (such as the `-H' option to GNU grep), it's a good idea to
73 include it when specifying `grep-command'.
74
75 The default value of this variable is set up by `grep-compute-defaults';
76 call that function before using this variable in your program."
77 :type '(choice string
78 (const :tag "Not Set" nil))
79 :group 'compilation)
80
81 (defcustom grep-use-null-device 'auto-detect
82 "If t, append the value of `null-device' to `grep' commands.
83 This is done to ensure that the output of grep includes the filename of
84 any match in the case where only a single file is searched, and is not
85 necessary if the grep program used supports the `-H' option.
86
87 The default value of this variable is set up by `grep-compute-defaults';
88 call that function before using this variable in your program."
89 :type 'boolean
90 :type '(choice (const :tag "Do Not Append Null Device" nil)
91 (const :tag "Append Null Device" t)
92 (other :tag "Not Set" auto-detect))
93 :group 'compilation)
94
95 (defcustom grep-find-command nil
96 "The default find command for \\[grep-find].
97 The default value of this variable is set up by `grep-compute-defaults';
98 call that function before using this variable in your program."
99 :type '(choice string
100 (const :tag "Not Set" nil))
101 :group 'compilation)
102
103 (defcustom grep-tree-command nil
104 "The default find command for \\[grep-tree].
105 The default value of this variable is set up by `grep-compute-defaults';
106 call that function before using this variable in your program.
107 The following place holders should be present in the string:
108 <D> - base directory for find
109 <X> - find options to restrict or expand the directory list
110 <F> - find options to limit the files matched
111 <C> - place to put -i if case insensitive grep
112 <R> - the regular expression searched for."
113 :type '(choice string
114 (const :tag "Not Set" nil))
115 :version "21.4"
116 :group 'compilation)
117
118 (defcustom grep-tree-files-aliases '(
119 ("ch" . "*.[ch]")
120 ("c" . "*.c")
121 ("h" . "*.h")
122 ("m" . "[Mm]akefile*")
123 ("asm" . "*.[sS]")
124 ("all" . "*")
125 ("el" . "*.el")
126 )
127 "*Alist of aliases for the FILES argument to `grep-tree'."
128 :type 'alist
129 :group 'compilation)
130
131 (defcustom grep-tree-ignore-case t
132 "*If non-nil, `grep-tree' ignores case in matches."
133 :type 'boolean
134 :group 'compilation)
135
136 (defcustom grep-tree-ignore-CVS-directories t
137 "*If non-nil, `grep-tree' does no recurse into CVS directories."
138 :type 'boolean
139 :group 'compilation)
140
141 (defvar compilation-error-list nil
142 "List of error message descriptors for visiting erring functions.
143 Each error descriptor is a cons (or nil). Its car is a marker pointing to
144 an error message. If its cdr is a marker, it points to the text of the
145 line the message is about. If its cdr is a cons, it is a list
146 \(\(DIRECTORY . FILE\) LINE [COLUMN]\). Or its cdr may be nil if that
147 error is not interesting.
148
149 The value may be t instead of a list; this means that the buffer of
150 error messages should be reparsed the next time the list of errors is wanted.
151
152 Some other commands (like `diff') use this list to control the error
153 message tracking facilities; if you change its structure, you should make
154 sure you also change those packages. Perhaps it is better not to change
155 it at all.")
156
157 (defvar compilation-old-error-list nil
158 "Value of `compilation-error-list' after errors were parsed.")
159
160 (defvar compilation-parse-errors-function 'compilation-parse-errors
161 "Function to call to parse error messages from a compilation.
162 It takes args LIMIT-SEARCH and FIND-AT-LEAST.
163 If LIMIT-SEARCH is non-nil, don't bother parsing past that location.
164 If FIND-AT-LEAST is non-nil, don't bother parsing after finding that
165 many new errors.
166 It should read in the source files which have errors and set
167 `compilation-error-list' to a list with an element for each error message
168 found. See that variable for more info.")
169
170 (defvar compilation-parse-errors-filename-function nil
171 "Function to call to post-process filenames while parsing error messages.
172 It takes one arg FILENAME which is the name of a file as found
173 in the compilation output, and should return a transformed file name.")
174
175 ;;;###autoload
176 (defvar compilation-process-setup-function nil
177 "*Function to call to customize the compilation process.
178 This functions is called immediately before the compilation process is
179 started. It can be used to set any variables or functions that are used
180 while processing the output of the compilation process.")
181
182 ;;;###autoload
183 (defvar compilation-buffer-name-function nil
184 "Function to compute the name of a compilation buffer.
185 The function receives one argument, the name of the major mode of the
186 compilation buffer. It should return a string.
187 nil means compute the name with `(concat \"*\" (downcase major-mode) \"*\")'.")
188
189 ;;;###autoload
190 (defvar compilation-finish-function nil
191 "Function to call when a compilation process finishes.
192 It is called with two arguments: the compilation buffer, and a string
193 describing how the process finished.")
194
195 ;;;###autoload
196 (defvar compilation-finish-functions nil
197 "Functions to call when a compilation process finishes.
198 Each function is called with two arguments: the compilation buffer,
199 and a string describing how the process finished.")
200
201 (defvar compilation-last-buffer nil
202 "The most recent compilation buffer.
203 A buffer becomes most recent when its compilation is started
204 or when it is used with \\[next-error] or \\[compile-goto-error].")
205
206 (defvar compilation-in-progress nil
207 "List of compilation processes now running.")
208 (or (assq 'compilation-in-progress minor-mode-alist)
209 (setq minor-mode-alist (cons '(compilation-in-progress " Compiling")
210 minor-mode-alist)))
211
212 (defvar compilation-parsing-end nil
213 "Marker position of end of buffer when last error messages were parsed.")
214
215 (defvar compilation-error-message "No more errors"
216 "Message to print when no more matches are found.")
217
218 (defvar compilation-arguments nil
219 "Arguments that were given to `compile-internal'.")
220
221 (defvar compilation-num-errors-found)
222
223 (defvar compilation-error-regexp-alist
224 '(
225 ;; NOTE! See also grep-regexp-alist, below.
226
227 ;; 4.3BSD grep, cc, lint pass 1:
228 ;; /usr/src/foo/foo.c(8): warning: w may be used before set
229 ;; or GNU utilities:
230 ;; foo.c:8: error message
231 ;; or HP-UX 7.0 fc:
232 ;; foo.f :16 some horrible error message
233 ;; or GNU utilities with column (GNAT 1.82):
234 ;; foo.adb:2:1: Unit name does not match file name
235 ;; or with column and program name:
236 ;; jade:dbcommon.dsl:133:17:E: missing argument for function call
237 ;;
238 ;; We'll insist that the number be followed by a colon or closing
239 ;; paren, because otherwise this matches just about anything
240 ;; containing a number with spaces around it.
241
242 ;; We insist on a non-digit in the file name
243 ;; so that we don't mistake the file name for a command name
244 ;; and take the line number as the file name.
245 ("\\([a-zA-Z][-a-zA-Z._0-9]+: ?\\)?\
246 \\([a-zA-Z]?:?[^:( \t\n]*[^:( \t\n0-9][^:( \t\n]*\\)[:(][ \t]*\\([0-9]+\\)\
247 \\([) \t]\\|:\\(\\([0-9]+:\\)\\|[0-9]*[^:0-9]\\)\\)" 2 3 6)
248
249 ;; GNU utilities with precise locations (line and columns),
250 ;; possibly ranges:
251 ;; foo.c:8.23-9.1: error message
252 ("\\([a-zA-Z][-a-zA-Z._0-9]+: ?\\)\
253 \\([0-9]+\\)\\.\\([0-9]+\\)\
254 -\\([0-9]+\\)\\.\\([0-9]+\\)\
255 :" 1 2 3) ;; When ending points are supported, add line = 4 and col = 5.
256 ;; foo.c:8.23-45: error message
257 ("\\([a-zA-Z][-a-zA-Z._0-9]+: ?\\)\
258 \\([0-9]+\\)\\.\\([0-9]+\\)\
259 -\\([0-9]+\\)\
260 :" 1 2 3) ;; When ending points are supported, add line = 2 and col = 4.
261 ;; foo.c:8-45.3: error message
262 ("\\([a-zA-Z][-a-zA-Z._0-9]+: ?\\)\
263 \\([0-9]+\\)\
264 -\\([0-9]+\\)\\.\\([0-9]+\\)\
265 :" 1 2 nil) ;; When ending points are supported, add line = 2 and col = 4.
266 ;; foo.c:8.23: error message
267 ("\\([a-zA-Z][-a-zA-Z._0-9]+: ?\\)\
268 \\([0-9]+\\)\\.\\([0-9]+\\)\
269 :" 1 2 3)
270 ;; foo.c:8-23: error message
271 ("\\([a-zA-Z][-a-zA-Z._0-9]+: ?\\)\
272 \\([0-9]+\\)\
273 -\\([0-9]+\\)\
274 :" 1 2 nil);; When ending points are supported, add line = 3.
275
276 ;; Microsoft C/C++:
277 ;; keyboard.c(537) : warning C4005: 'min' : macro redefinition
278 ;; d:\tmp\test.c(23) : error C2143: syntax error : missing ';' before 'if'
279 ;; This used to be less selective and allow characters other than
280 ;; parens around the line number, but that caused confusion for
281 ;; GNU-style error messages.
282 ;; This used to reject spaces and dashes in file names,
283 ;; but they are valid now; so I made it more strict about the error
284 ;; message that follows.
285 ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \
286 : \\(error\\|warning\\) C[0-9]+:" 1 3)
287
288 ;; Borland C++, C++Builder:
289 ;; Error ping.c 15: Unable to open include file 'sys/types.h'
290 ;; Warning ping.c 68: Call to function 'func' with no prototype
291 ;; Error E2010 ping.c 15: Unable to open include file 'sys/types.h'
292 ;; Warning W1022 ping.c 68: Call to function 'func' with no prototype
293 ("\\(Error\\|Warning\\) \\(\\([FEW][0-9]+\\) \\)?\
294 \\([a-zA-Z]?:?[^:( \t\n]+\\)\
295 \\([0-9]+\\)\\([) \t]\\|:[^0-9\n]\\)" 4 5)
296
297 ;; Valgrind (memory debugger for x86 GNU/Linux):
298 ;; ==1332== at 0x8008621: main (vtest.c:180)
299 ;; Currently this regexp only matches the first error.
300 ;; Thanks to Hans Petter Jansson <hpj@ximian.com> for his regexp wisdom.
301 ("^==[0-9]+==[^(]+\(([^:]+):([0-9]+)" 1 2)
302
303 ;; 4.3BSD lint pass 2
304 ;; strcmp: variable # of args. llib-lc(359) :: /usr/src/foo/foo.c(8)
305 (".*[ \t:]\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(](+[ \t]*\\([0-9]+\\))[:) \t]*$"
306 1 2)
307
308 ;; 4.3BSD lint pass 3
309 ;; bloofle defined( /users/wolfgang/foo.c(4) ), but never used
310 ;; This used to be
311 ;; ("[ \t(]+\\([a-zA-Z]?:?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]+" 1 2)
312 ;; which is regexp Impressionism - it matches almost anything!
313 (".*([ \t]*\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\))" 1 2)
314
315 ;; MIPS lint pass<n>; looks good for SunPro lint also
316 ;; TrimMask (255) in solomon.c may be indistinguishable from TrimMasks (93) in solomon.c due to truncation
317 ("[^\n ]+ (\\([0-9]+\\)) in \\([^ \n]+\\)" 2 1)
318 ;; name defined but never used: LinInt in cmap_calc.c(199)
319 (".*in \\([^(\n]+\\)(\\([0-9]+\\))$" 1 2)
320
321 ;; Ultrix 3.0 f77:
322 ;; fort: Severe: addstf.f, line 82: Missing operator or delimiter symbol
323 ;; Some SGI cc version:
324 ;; cfe: Warning 835: foo.c, line 2: something
325 ("\\(cfe\\|fort\\): [^:\n]*: \\([^ \n]*\\), line \\([0-9]+\\):" 2 3)
326 ;; Error on line 3 of t.f: Execution error unclassifiable statement
327 ;; Unknown who does this:
328 ;; Line 45 of "foo.c": bloofle undefined
329 ;; Absoft FORTRAN 77 Compiler 3.1.3
330 ;; error on line 19 of fplot.f: spelling error?
331 ;; warning on line 17 of fplot.f: data type is undefined for variable d
332 ("\\(.* on \\)?[Ll]ine[ \t]+\\([0-9]+\\)[ \t]+\
333 of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2)
334
335 ;; Apollo cc, 4.3BSD fc:
336 ;; "foo.f", line 3: Error: syntax error near end of statement
337 ;; IBM RS6000:
338 ;; "vvouch.c", line 19.5: 1506-046 (S) Syntax error.
339 ;; Microtec mcc68k:
340 ;; "foo.c", line 32 pos 1; (E) syntax error; unexpected symbol: "lossage"
341 ;; GNAT (as of July 94):
342 ;; "foo.adb", line 2(11): warning: file name does not match ...
343 ;; IBM AIX xlc compiler:
344 ;; "src/swapping.c", line 30.34: 1506-342 (W) "/*" detected in comment.
345 (".*\"\\([^,\" \n\t]+\\)\", lines? \
346 \\([0-9]+\\)\\([\(.]\\([0-9]+\\)\)?\\)?[:., (-]" 1 2 4)
347
348 ;; Python:
349 ;; File "foobar.py", line 5, blah blah
350 ("^File \"\\([^,\" \n\t]+\\)\", line \\([0-9]+\\)," 1 2)
351
352 ;; Caml compiler:
353 ;; File "foobar.ml", lines 5-8, characters 20-155: blah blah
354 ("^File \"\\([^,\" \n\t]+\\)\", lines? \\([0-9]+\\)[-0-9]*, characters? \\([0-9]+\\)" 1 2 3)
355
356 ;; MIPS RISC CC - the one distributed with Ultrix:
357 ;; ccom: Error: foo.c, line 2: syntax error
358 ;; DEC AXP OSF/1 cc
359 ;; /usr/lib/cmplrs/cc/cfe: Error: foo.c: 1: blah blah
360 ("[a-z0-9/]+: \\([eE]rror\\|[wW]arning\\): \\([^,\" \n\t]+\\)[,:] \\(line \\)?\\([0-9]+\\):" 2 4)
361
362 ;; IBM AIX PS/2 C version 1.1:
363 ;; ****** Error number 140 in line 8 of file errors.c ******
364 (".*in line \\([0-9]+\\) of file \\([^ \n]+[^. \n]\\)\\.? " 2 1)
365 ;; IBM AIX lint is too painful to do right this way. File name
366 ;; prefixes entire sections rather than being on each line.
367
368 ;; SPARCcompiler Pascal:
369 ;; 20 linjer : array[1..4] of linje;
370 ;; e 18480-----------^--- Inserted ';'
371 ;; and
372 ;; E 18520 line 61 - 0 is undefined
373 ;; These messages don't contain a file name. Instead the compiler gives
374 ;; a message whenever the file being compiled is changed.
375 (" +\\([0-9]+\\) +.*\n[ew] [0-9]+-+" nil 1)
376 ("[Ew] +[0-9]+ line \\([0-9]+\\) - " nil 1)
377
378 ;; Lucid Compiler, lcc 3.x
379 ;; E, file.cc(35,52) Illegal operation on pointers
380 ("[EW], \\([^(\n]*\\)(\\([0-9]+\\),[ \t]*\\([0-9]+\\)" 1 2 3)
381
382 ;; This seems to be superfluous because the first pattern matches it.
383 ;; ;; GNU messages with program name and optional column number.
384 ;; ("[a-zA-Z]?:?[^0-9 \n\t:]+[^ \n\t:]*:[ \t]*\\([^ \n\t:]+\\):\
385 ;;\\([0-9]+\\):\\(\\([0-9]+\\)[: \t]\\)?" 1 2 4)
386
387 ;; Cray C compiler error messages
388 ("\\(cc\\| cft\\)-[0-9]+ c\\(c\\|f77\\): ERROR \\([^,\n]+, \\)* File = \
389 \\([^,\n]+\\), Line = \\([0-9]+\\)" 4 5)
390
391 ;; IBM C/C++ Tools 2.01:
392 ;; foo.c(2:0) : informational EDC0804: Function foo is not referenced.
393 ;; foo.c(3:8) : warning EDC0833: Implicit return statement encountered.
394 ;; foo.c(5:5) : error EDC0350: Syntax error.
395 ("\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) : " 1 2 3)
396
397 ;; IAR Systems C Compiler:
398 ;; "foo.c",3 Error[32]: Error message
399 ;; "foo.c",3 Warning[32]: Error message
400 ("\"\\(.*\\)\",\\([0-9]+\\)\\s-+\\(Error\\|Warning\\)\\[[0-9]+\\]:" 1 2)
401
402 ;; Sun ada (VADS, Solaris):
403 ;; /home3/xdhar/rcds_rc/main.a, line 361, char 6:syntax error: "," inserted
404 ("\\([^, \n\t]+\\), line \\([0-9]+\\), char \\([0-9]+\\)[:., \(-]" 1 2 3)
405
406 ;; Perl -w:
407 ;; syntax error at automake line 922, near "':'"
408 ;; Perl debugging traces
409 ;; store::odrecall('File_A', 'x2') called at store.pm line 90
410 (".* at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 1 2)
411
412 ;; Oracle pro*c:
413 ;; Semantic error at line 528, column 5, file erosacqdb.pc:
414 ("Semantic error at line \\([0-9]+\\), column \\([0-9]+\\), file \\(.*\\):"
415 3 1 2)
416
417 ;; EPC F90 compiler:
418 ;; Error 24 at (2:progran.f90) : syntax error
419 ("Error [0-9]+ at (\\([0-9]*\\):\\([^)\n]+\\))" 2 1)
420
421 ;; SGI IRIX MipsPro 7.3 compilers:
422 ;; cc-1070 cc: ERROR File = linkl.c, Line = 38
423 (".*: ERROR File = \\(.+\\), Line = \\([0-9]+\\)" 1 2)
424 (".*: WARNING File = \\(.+\\), Line = \\([0-9]+\\)" 1 2)
425
426 ;; Sun F90 error messages:
427 ;; cf90-113 f90comp: ERROR NSE, File = Hoved.f90, Line = 16, Column = 3
428 (".* ERROR [a-zA-Z0-9 ]+, File = \\(.+\\), Line = \\([0-9]+\\), Column = \\([0-9]+\\)"
429 1 2 3)
430
431 ;; RXP - GPL XML validator at http://www.cogsci.ed.ac.uk/~richard/rxp.html:
432 ;; Error: Mismatched end tag: expected </geroup>, got </group>
433 ;; in unnamed entity at line 71 char 8 of file:///home/reto/test/group.xml
434 ("Error:.*\n.* line \\([0-9]+\\) char \\([0-9]+\\) of file://\\(.+\\)"
435 3 1 2)
436 ;; Warning: Start tag for undeclared element geroup
437 ;; in unnamed entity at line 4 char 8 of file:///home/reto/test/group.xml
438 ("Warning:.*\n.* line \\([0-9]+\\) char \\([0-9]+\\) of file://\\(.+\\)"
439 3 1 2)
440 )
441
442 "Alist that specifies how to match errors in compiler output.
443 Each elt has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX FILE-FORMAT...])
444 If REGEXP matches, the FILE-IDX'th subexpression gives the file name, and
445 the LINE-IDX'th subexpression gives the line number. If COLUMN-IDX is
446 given, the COLUMN-IDX'th subexpression gives the column number on that line.
447 If any FILE-FORMAT is given, each is a format string to produce a file name to
448 try; %s in the string is replaced by the text matching the FILE-IDX'th
449 subexpression.")
450
451 (defvar compilation-enter-directory-regexp-alist
452 '(
453 ;; Matches lines printed by the `-w' option of GNU Make.
454 (".*: Entering directory `\\(.*\\)'$" 1)
455 )
456 "Alist specifying how to match lines that indicate a new current directory.
457 Note that the match is done at the beginning of lines.
458 Each elt has the form (REGEXP IDX).
459 If REGEXP matches, the IDX'th subexpression gives the directory name.
460
461 The default value matches lines printed by the `-w' option of GNU Make.")
462
463 (defvar compilation-leave-directory-regexp-alist
464 '(
465 ;; Matches lines printed by the `-w' option of GNU Make.
466 (".*: Leaving directory `\\(.*\\)'$" 1)
467 )
468 "Alist specifying how to match lines that indicate restoring current directory.
469 Note that the match is done at the beginning of lines.
470 Each elt has the form (REGEXP IDX).
471 If REGEXP matches, the IDX'th subexpression gives the name of the directory
472 being moved from. If IDX is nil, the last directory entered \(by a line
473 matching `compilation-enter-directory-regexp-alist'\) is assumed.
474
475 The default value matches lines printed by the `-w' option of GNU Make.")
476
477 (defvar compilation-file-regexp-alist
478 '(
479 ;; This matches entries with date time year file-name: like
480 ;; Thu May 14 10:46:12 1992 mom3.p:
481 ("\\w\\w\\w \\w\\w\\w +[0-9]+ [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9] \\(.*\\):$" 1)
482 )
483 "Alist specifying how to match lines that indicate a new current file.
484 Note that the match is done at the beginning of lines.
485 Each elt has the form (REGEXP IDX).
486 If REGEXP matches, the IDX'th subexpression gives the file name. This is
487 used with compilers that don't indicate file name in every error message.")
488
489 ;; There is no generally useful regexp that will match non messages, but
490 ;; in special cases there might be one. The lines that are not matched by
491 ;; a regexp take much longer time than the ones that are recognized so if
492 ;; you have same regexeps here, parsing is faster.
493 (defvar compilation-nomessage-regexp-alist
494 '(
495 )
496 "Alist specifying how to match lines that have no message.
497 Note that the match is done at the beginning of lines.
498 Each elt has the form (REGEXP). This alist is by default empty, but if
499 you have some good regexps here, the parsing of messages will be faster.")
500
501 (defcustom compilation-error-screen-columns t
502 "*If non-nil, column numbers in error messages are screen columns.
503 Otherwise they are interpreted as character positions, with
504 each character occupying one column.
505 The default is to use screen columns, which requires that the compilation
506 program and Emacs agree about the display width of the characters,
507 especially the TAB character."
508 :type 'boolean
509 :group 'compilation
510 :version "20.4")
511
512 (defcustom compilation-read-command t
513 "*Non-nil means \\[compile] reads the compilation command to use.
514 Otherwise, \\[compile] just uses the value of `compile-command'."
515 :type 'boolean
516 :group 'compilation)
517
518 ;;;###autoload
519 (defcustom compilation-ask-about-save t
520 "*Non-nil means \\[compile] asks which buffers to save before compiling.
521 Otherwise, it saves all modified buffers without asking."
522 :type 'boolean
523 :group 'compilation)
524
525 ;; Note: the character class after the optional drive letter does not
526 ;; include a space to support file names with blanks.
527 (defvar grep-regexp-alist
528 '(("\\([a-zA-Z]?:?[^:(\t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 2))
529 "Regexp used to match grep hits. See `compilation-error-regexp-alist'.")
530
531 (defvar grep-program
532 ;; Currently zgrep has trouble. It runs egrep instead of grep,
533 ;; and it doesn't pass along long options right.
534 "grep"
535 ;; (if (equal (condition-case nil ; in case "zgrep" isn't in exec-path
536 ;; (call-process "zgrep" nil nil nil
537 ;; "foo" null-device)
538 ;; (error nil))
539 ;; 1)
540 ;; "zgrep"
541 ;; "grep")
542 "The default grep program for `grep-command' and `grep-find-command'.
543 This variable's value takes effect when `grep-compute-defaults' is called.")
544
545 (defvar find-program "find"
546 "The default find program for `grep-find-command'.
547 This variable's value takes effect when `grep-compute-defaults' is called.")
548
549 (defvar grep-find-use-xargs nil
550 "Whether \\[grep-find] uses the `xargs' utility by default.
551
552 If nil, it uses `find -exec'; if `gnu', it uses `find -print0' and `xargs -0';
553 if not nil and not `gnu', it uses `find -print' and `xargs'.
554
555 This variable's value takes effect when `grep-compute-defaults' is called.")
556
557 ;;;###autoload
558 (defcustom compilation-search-path '(nil)
559 "*List of directories to search for source files named in error messages.
560 Elements should be directory names, not file names of directories.
561 nil as an element means to try the default directory."
562 :type '(repeat (choice (const :tag "Default" nil)
563 (string :tag "Directory")))
564 :group 'compilation)
565
566 (defcustom compile-command "make -k "
567 "*Last shell command used to do a compilation; default for next compilation.
568
569 Sometimes it is useful for files to supply local values for this variable.
570 You might also use mode hooks to specify it in certain modes, like this:
571
572 (add-hook 'c-mode-hook
573 (lambda ()
574 (unless (or (file-exists-p \"makefile\")
575 (file-exists-p \"Makefile\"))
576 (set (make-local-variable 'compile-command)
577 (concat \"make -k \"
578 (file-name-sans-extension buffer-file-name))))))"
579 :type 'string
580 :group 'compilation)
581
582 (defvar compilation-directory-stack nil
583 "Stack of previous directories for `compilation-leave-directory-regexp'.
584 The last element is the directory the compilation was started in.")
585
586 (defvar compilation-exit-message-function nil "\
587 If non-nil, called when a compilation process dies to return a status message.
588 This should be a function of three arguments: process status, exit status,
589 and exit message; it returns a cons (MESSAGE . MODELINE) of the strings to
590 write into the compilation buffer, and to put in its mode line.")
591
592 ;; History of compile commands.
593 (defvar compile-history nil)
594 ;; History of grep commands.
595 (defvar grep-history nil)
596 (defvar grep-find-history nil)
597
598 (defun compilation-mode-font-lock-keywords ()
599 "Return expressions to highlight in Compilation mode."
600 (nconc
601 ;;
602 ;; Compiler warning/error lines.
603 (mapcar (function
604 (lambda (item)
605 ;; Prepend "^", adjusting FILE-IDX and LINE-IDX accordingly.
606 (let ((file-idx (nth 1 item))
607 (line-idx (nth 2 item))
608 (col-idx (nth 3 item))
609 keyword)
610 (when (numberp col-idx)
611 (setq keyword
612 (cons (list (1+ col-idx) 'font-lock-type-face nil t)
613 keyword)))
614 (when (numberp line-idx)
615 (setq keyword
616 (cons (list (1+ line-idx) 'font-lock-variable-name-face)
617 keyword)))
618 (when (numberp file-idx)
619 (setq keyword
620 (cons (list (1+ file-idx) 'font-lock-warning-face)
621 keyword)))
622 (cons (concat "^\\(" (nth 0 item) "\\)") keyword))))
623 compilation-error-regexp-alist)
624 (list
625 ;;
626 ;; Compiler output lines. Recognize `make[n]:' lines too.
627 '("^\\([A-Za-z_0-9/\.+-]+\\)\\(\\[\\([0-9]+\\)\\]\\)?[ \t]*:"
628 (1 font-lock-function-name-face) (3 font-lock-comment-face nil t)))
629 ))
630
631 ;;;###autoload
632 (defun compile (command)
633 "Compile the program including the current buffer. Default: run `make'.
634 Runs COMMAND, a shell command, in a separate process asynchronously
635 with output going to the buffer `*compilation*'.
636
637 You can then use the command \\[next-error] to find the next error message
638 and move to the source code that caused it.
639
640 Interactively, prompts for the command if `compilation-read-command' is
641 non-nil; otherwise uses `compile-command'. With prefix arg, always prompts.
642
643 To run more than one compilation at once, start one and rename the
644 \`*compilation*' buffer to some other name with \\[rename-buffer].
645 Then start the next one.
646
647 The name used for the buffer is actually whatever is returned by
648 the function in `compilation-buffer-name-function', so you can set that
649 to a function that generates a unique name."
650 (interactive
651 (if (or compilation-read-command current-prefix-arg)
652 (list (read-from-minibuffer "Compile command: "
653 (eval compile-command) nil nil
654 '(compile-history . 1)))
655 (list (eval compile-command))))
656 (unless (equal command (eval compile-command))
657 (setq compile-command command))
658 (save-some-buffers (not compilation-ask-about-save) nil)
659 (compile-internal command "No more errors"))
660
661 ;; run compile with the default command line
662 (defun recompile ()
663 "Re-compile the program including the current buffer.
664 If this is run in a compilation-mode buffer, re-use the arguments from the
665 original use. Otherwise, it recompiles using `compile-command'."
666 (interactive)
667 (save-some-buffers (not compilation-ask-about-save) nil)
668 (apply 'compile-internal (or compilation-arguments
669 `(,(eval compile-command) "No more errors"))))
670
671 (defun grep-process-setup ()
672 "Set up `compilation-exit-message-function' for `grep'."
673 (set (make-local-variable 'compilation-exit-message-function)
674 (lambda (status code msg)
675 (if (eq status 'exit)
676 (cond ((zerop code)
677 '("finished (matches found)\n" . "matched"))
678 ((= code 1)
679 '("finished with no matches found\n" . "no match"))
680 (t
681 (cons msg code)))
682 (cons msg code)))))
683
71 (defun grep-compute-defaults () 684 (defun grep-compute-defaults ()
72 (unless (or (not grep-use-null-device) (eq grep-use-null-device t)) 685 (unless (or (not grep-use-null-device) (eq grep-use-null-device t))
73 (setq grep-use-null-device 686 (setq grep-use-null-device
74 (with-temp-buffer 687 (with-temp-buffer
75 (let ((hello-file (expand-file-name "HELLO" data-directory))) 688 (let ((hello-file (expand-file-name "HELLO" data-directory)))
107 (equal (call-process "find" nil nil nil 720 (equal (call-process "find" nil nil nil
108 null-device "-print0") 721 null-device "-print0")
109 0) 722 0)
110 (equal (call-process "xargs" nil nil nil 723 (equal (call-process "xargs" nil nil nil
111 "-0" "-e" "echo") 724 "-0" "-e" "echo")
112 0)) 725 0))
113 'gnu))) 726 'gnu)))
114 (unless grep-find-command 727 (unless grep-find-command
115 (setq grep-find-command 728 (setq grep-find-command
116 (cond ((eq grep-find-use-xargs 'gnu) 729 (cond ((eq grep-find-use-xargs 'gnu)
117 (format "%s . -type f -print0 | xargs -0 -e %s" 730 (format "%s . -type f -print0 | xargs -0 -e %s"
132 (grep-find-use-xargs 745 (grep-find-use-xargs
133 (format "%s <D> <X> -type f <F> -print | xargs %s <R>" 746 (format "%s <D> <X> -type f <F> -print | xargs %s <R>"
134 find-program gcmd)) 747 find-program gcmd))
135 (t (format "%s <D> <X> -type f <F> -exec %s <R> {} %s \\;" 748 (t (format "%s <D> <X> -type f <F> -exec %s <R> {} %s \\;"
136 find-program gcmd null-device))))))) 749 find-program gcmd null-device)))))))
137
138 (defcustom grep-command nil
139 "The default grep command for \\[grep].
140 If the grep program used supports an option to always include file names
141 in its output (such as the `-H' option to GNU grep), it's a good idea to
142 include it when specifying `grep-command'.
143
144 The default value of this variable is set up by `grep-compute-defaults';
145 call that function before using this variable in your program."
146 :type '(choice string
147 (const :tag "Not Set" nil))
148 :group 'compilation)
149
150 (defcustom grep-use-null-device 'auto-detect
151 "If t, append the value of `null-device' to `grep' commands.
152 This is done to ensure that the output of grep includes the filename of
153 any match in the case where only a single file is searched, and is not
154 necessary if the grep program used supports the `-H' option.
155
156 The default value of this variable is set up by `grep-compute-defaults';
157 call that function before using this variable in your program."
158 :type 'boolean
159 :type '(choice (const :tag "Do Not Append Null Device" nil)
160 (const :tag "Append Null Device" t)
161 (other :tag "Not Set" auto-detect))
162 :group 'compilation)
163
164 (defcustom grep-find-command nil
165 "The default find command for \\[grep-find].
166 The default value of this variable is set up by `grep-compute-defaults';
167 call that function before using this variable in your program."
168 :type '(choice string
169 (const :tag "Not Set" nil))
170 :group 'compilation)
171
172 (defcustom grep-tree-command nil
173 "The default find command for \\[grep-tree].
174 The default value of this variable is set up by `grep-compute-defaults';
175 call that function before using this variable in your program.
176 The following place holders should be present in the string:
177 <D> - base directory for find
178 <X> - find options to restrict or expand the directory list
179 <F> - find options to limit the files matched
180 <C> - place to put -i if case insensitive grep
181 <R> - the regular expression searched for."
182 :type '(choice string
183 (const :tag "Not Set" nil))
184 :version "21.4"
185 :group 'compilation)
186
187 (defcustom grep-tree-files-aliases '(
188 ("ch" . "*.[ch]")
189 ("c" . "*.c")
190 ("h" . "*.h")
191 ("m" . "[Mm]akefile*")
192 ("asm" . "*.[sS]")
193 ("all" . "*")
194 ("el" . "*.el")
195 )
196 "*Alist of aliases for the FILES argument to `grep-tree'."
197 :type 'alist
198 :group 'compilation)
199
200 (defcustom grep-tree-ignore-case t
201 "*If non-nil, `grep-tree' ignores case in matches."
202 :type 'boolean
203 :group 'compilation)
204
205 (defcustom grep-tree-ignore-CVS-directories t
206 "*If non-nil, `grep-tree' does no recurse into CVS directories."
207 :type 'boolean
208 :group 'compilation)
209
210 (defvar compilation-error-list nil
211 "List of error message descriptors for visiting erring functions.
212 Each error descriptor is a cons (or nil). Its car is a marker pointing to
213 an error message. If its cdr is a marker, it points to the text of the
214 line the message is about. If its cdr is a cons, it is a list
215 \(\(DIRECTORY . FILE\) LINE [COLUMN]\). Or its cdr may be nil if that
216 error is not interesting.
217
218 The value may be t instead of a list; this means that the buffer of
219 error messages should be reparsed the next time the list of errors is wanted.
220
221 Some other commands (like `diff') use this list to control the error
222 message tracking facilities; if you change its structure, you should make
223 sure you also change those packages. Perhaps it is better not to change
224 it at all.")
225
226 (defvar compilation-old-error-list nil
227 "Value of `compilation-error-list' after errors were parsed.")
228
229 (defvar compilation-parse-errors-function 'compilation-parse-errors
230 "Function to call to parse error messages from a compilation.
231 It takes args LIMIT-SEARCH and FIND-AT-LEAST.
232 If LIMIT-SEARCH is non-nil, don't bother parsing past that location.
233 If FIND-AT-LEAST is non-nil, don't bother parsing after finding that
234 many new errors.
235 It should read in the source files which have errors and set
236 `compilation-error-list' to a list with an element for each error message
237 found. See that variable for more info.")
238
239 (defvar compilation-parse-errors-filename-function nil
240 "Function to call to post-process filenames while parsing error messages.
241 It takes one arg FILENAME which is the name of a file as found
242 in the compilation output, and should return a transformed file name.")
243
244 ;;;###autoload
245 (defvar compilation-process-setup-function nil
246 "*Function to call to customize the compilation process.
247 This functions is called immediately before the compilation process is
248 started. It can be used to set any variables or functions that are used
249 while processing the output of the compilation process.")
250
251 ;;;###autoload
252 (defvar compilation-buffer-name-function nil
253 "Function to compute the name of a compilation buffer.
254 The function receives one argument, the name of the major mode of the
255 compilation buffer. It should return a string.
256 nil means compute the name with `(concat \"*\" (downcase major-mode) \"*\")'.")
257
258 ;;;###autoload
259 (defvar compilation-finish-function nil
260 "Function to call when a compilation process finishes.
261 It is called with two arguments: the compilation buffer, and a string
262 describing how the process finished.")
263
264 ;;;###autoload
265 (defvar compilation-finish-functions nil
266 "Functions to call when a compilation process finishes.
267 Each function is called with two arguments: the compilation buffer,
268 and a string describing how the process finished.")
269
270 (defvar compilation-last-buffer nil
271 "The most recent compilation buffer.
272 A buffer becomes most recent when its compilation is started
273 or when it is used with \\[next-error] or \\[compile-goto-error].")
274
275 (defvar compilation-in-progress nil
276 "List of compilation processes now running.")
277 (or (assq 'compilation-in-progress minor-mode-alist)
278 (setq minor-mode-alist (cons '(compilation-in-progress " Compiling")
279 minor-mode-alist)))
280
281 (defvar compilation-parsing-end nil
282 "Marker position of end of buffer when last error messages were parsed.")
283
284 (defvar compilation-error-message "No more errors"
285 "Message to print when no more matches are found.")
286
287 (defvar compilation-arguments nil
288 "Arguments that were given to `compile-internal'.")
289
290 (defvar compilation-num-errors-found)
291
292 (defvar compilation-error-regexp-alist
293 '(
294 ;; NOTE! See also grep-regexp-alist, below.
295
296 ;; 4.3BSD grep, cc, lint pass 1:
297 ;; /usr/src/foo/foo.c(8): warning: w may be used before set
298 ;; or GNU utilities:
299 ;; foo.c:8: error message
300 ;; or HP-UX 7.0 fc:
301 ;; foo.f :16 some horrible error message
302 ;; or GNU utilities with column (GNAT 1.82):
303 ;; foo.adb:2:1: Unit name does not match file name
304 ;; or with column and program name:
305 ;; jade:dbcommon.dsl:133:17:E: missing argument for function call
306 ;;
307 ;; We'll insist that the number be followed by a colon or closing
308 ;; paren, because otherwise this matches just about anything
309 ;; containing a number with spaces around it.
310
311 ;; We insist on a non-digit in the file name
312 ;; so that we don't mistake the file name for a command name
313 ;; and take the line number as the file name.
314 ("\\([a-zA-Z][-a-zA-Z._0-9]+: ?\\)?\
315 \\([a-zA-Z]?:?[^:( \t\n]*[^:( \t\n0-9][^:( \t\n]*\\)[:(][ \t]*\\([0-9]+\\)\
316 \\([) \t]\\|:\\(\\([0-9]+:\\)\\|[0-9]*[^:0-9]\\)\\)" 2 3 6)
317
318 ;; GNU utilities with precise locations (line and columns),
319 ;; possibly ranges:
320 ;; foo.c:8.23-9.1: error message
321 ("\\([a-zA-Z][-a-zA-Z._0-9]+: ?\\)\
322 \\([0-9]+\\)\\.\\([0-9]+\\)\
323 -\\([0-9]+\\)\\.\\([0-9]+\\)\
324 :" 1 2 3) ;; When ending points are supported, add line = 4 and col = 5.
325 ;; foo.c:8.23-45: error message
326 ("\\([a-zA-Z][-a-zA-Z._0-9]+: ?\\)\
327 \\([0-9]+\\)\\.\\([0-9]+\\)\
328 -\\([0-9]+\\)\
329 :" 1 2 3) ;; When ending points are supported, add line = 2 and col = 4.
330 ;; foo.c:8-45.3: error message
331 ("\\([a-zA-Z][-a-zA-Z._0-9]+: ?\\)\
332 \\([0-9]+\\)\
333 -\\([0-9]+\\)\\.\\([0-9]+\\)\
334 :" 1 2 nil) ;; When ending points are supported, add line = 2 and col = 4.
335 ;; foo.c:8.23: error message
336 ("\\([a-zA-Z][-a-zA-Z._0-9]+: ?\\)\
337 \\([0-9]+\\)\\.\\([0-9]+\\)\
338 :" 1 2 3)
339 ;; foo.c:8-23: error message
340 ("\\([a-zA-Z][-a-zA-Z._0-9]+: ?\\)\
341 \\([0-9]+\\)\
342 -\\([0-9]+\\)\
343 :" 1 2 nil);; When ending points are supported, add line = 3.
344
345 ;; Microsoft C/C++:
346 ;; keyboard.c(537) : warning C4005: 'min' : macro redefinition
347 ;; d:\tmp\test.c(23) : error C2143: syntax error : missing ';' before 'if'
348 ;; This used to be less selective and allow characters other than
349 ;; parens around the line number, but that caused confusion for
350 ;; GNU-style error messages.
351 ;; This used to reject spaces and dashes in file names,
352 ;; but they are valid now; so I made it more strict about the error
353 ;; message that follows.
354 ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \
355 : \\(error\\|warning\\) C[0-9]+:" 1 3)
356
357 ;; Borland C++, C++Builder:
358 ;; Error ping.c 15: Unable to open include file 'sys/types.h'
359 ;; Warning ping.c 68: Call to function 'func' with no prototype
360 ;; Error E2010 ping.c 15: Unable to open include file 'sys/types.h'
361 ;; Warning W1022 ping.c 68: Call to function 'func' with no prototype
362 ("\\(Error\\|Warning\\) \\(\\([FEW][0-9]+\\) \\)?\
363 \\([a-zA-Z]?:?[^:( \t\n]+\\)\
364 \\([0-9]+\\)\\([) \t]\\|:[^0-9\n]\\)" 4 5)
365
366 ;; Valgrind (memory debugger for x86 GNU/Linux):
367 ;; ==1332== at 0x8008621: main (vtest.c:180)
368 ;; Currently this regexp only matches the first error.
369 ;; Thanks to Hans Petter Jansson <hpj@ximian.com> for his regexp wisdom.
370 ("^==[0-9]+==[^(]+\(([^:]+):([0-9]+)" 1 2)
371
372 ;; 4.3BSD lint pass 2
373 ;; strcmp: variable # of args. llib-lc(359) :: /usr/src/foo/foo.c(8)
374 (".*[ \t:]\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(](+[ \t]*\\([0-9]+\\))[:) \t]*$"
375 1 2)
376
377 ;; 4.3BSD lint pass 3
378 ;; bloofle defined( /users/wolfgang/foo.c(4) ), but never used
379 ;; This used to be
380 ;; ("[ \t(]+\\([a-zA-Z]?:?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]+" 1 2)
381 ;; which is regexp Impressionism - it matches almost anything!
382 (".*([ \t]*\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\))" 1 2)
383
384 ;; MIPS lint pass<n>; looks good for SunPro lint also
385 ;; TrimMask (255) in solomon.c may be indistinguishable from TrimMasks (93) in solomon.c due to truncation
386 ("[^\n ]+ (\\([0-9]+\\)) in \\([^ \n]+\\)" 2 1)
387 ;; name defined but never used: LinInt in cmap_calc.c(199)
388 (".*in \\([^(\n]+\\)(\\([0-9]+\\))$" 1 2)
389
390 ;; Ultrix 3.0 f77:
391 ;; fort: Severe: addstf.f, line 82: Missing operator or delimiter symbol
392 ;; Some SGI cc version:
393 ;; cfe: Warning 835: foo.c, line 2: something
394 ("\\(cfe\\|fort\\): [^:\n]*: \\([^ \n]*\\), line \\([0-9]+\\):" 2 3)
395 ;; Error on line 3 of t.f: Execution error unclassifiable statement
396 ;; Unknown who does this:
397 ;; Line 45 of "foo.c": bloofle undefined
398 ;; Absoft FORTRAN 77 Compiler 3.1.3
399 ;; error on line 19 of fplot.f: spelling error?
400 ;; warning on line 17 of fplot.f: data type is undefined for variable d
401 ("\\(.* on \\)?[Ll]ine[ \t]+\\([0-9]+\\)[ \t]+\
402 of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2)
403
404 ;; Apollo cc, 4.3BSD fc:
405 ;; "foo.f", line 3: Error: syntax error near end of statement
406 ;; IBM RS6000:
407 ;; "vvouch.c", line 19.5: 1506-046 (S) Syntax error.
408 ;; Microtec mcc68k:
409 ;; "foo.c", line 32 pos 1; (E) syntax error; unexpected symbol: "lossage"
410 ;; GNAT (as of July 94):
411 ;; "foo.adb", line 2(11): warning: file name does not match ...
412 ;; IBM AIX xlc compiler:
413 ;; "src/swapping.c", line 30.34: 1506-342 (W) "/*" detected in comment.
414 (".*\"\\([^,\" \n\t]+\\)\", lines? \
415 \\([0-9]+\\)\\([\(.]\\([0-9]+\\)\)?\\)?[:., (-]" 1 2 4)
416
417 ;; Python:
418 ;; File "foobar.py", line 5, blah blah
419 ("^File \"\\([^,\" \n\t]+\\)\", line \\([0-9]+\\)," 1 2)
420
421 ;; Caml compiler:
422 ;; File "foobar.ml", lines 5-8, characters 20-155: blah blah
423 ("^File \"\\([^,\" \n\t]+\\)\", lines? \\([0-9]+\\)[-0-9]*, characters? \\([0-9]+\\)" 1 2 3)
424
425 ;; MIPS RISC CC - the one distributed with Ultrix:
426 ;; ccom: Error: foo.c, line 2: syntax error
427 ;; DEC AXP OSF/1 cc
428 ;; /usr/lib/cmplrs/cc/cfe: Error: foo.c: 1: blah blah
429 ("[a-z0-9/]+: \\([eE]rror\\|[wW]arning\\): \\([^,\" \n\t]+\\)[,:] \\(line \\)?\\([0-9]+\\):" 2 4)
430
431 ;; IBM AIX PS/2 C version 1.1:
432 ;; ****** Error number 140 in line 8 of file errors.c ******
433 (".*in line \\([0-9]+\\) of file \\([^ \n]+[^. \n]\\)\\.? " 2 1)
434 ;; IBM AIX lint is too painful to do right this way. File name
435 ;; prefixes entire sections rather than being on each line.
436
437 ;; SPARCcompiler Pascal:
438 ;; 20 linjer : array[1..4] of linje;
439 ;; e 18480-----------^--- Inserted ';'
440 ;; and
441 ;; E 18520 line 61 - 0 is undefined
442 ;; These messages don't contain a file name. Instead the compiler gives
443 ;; a message whenever the file being compiled is changed.
444 (" +\\([0-9]+\\) +.*\n[ew] [0-9]+-+" nil 1)
445 ("[Ew] +[0-9]+ line \\([0-9]+\\) - " nil 1)
446
447 ;; Lucid Compiler, lcc 3.x
448 ;; E, file.cc(35,52) Illegal operation on pointers
449 ("[EW], \\([^(\n]*\\)(\\([0-9]+\\),[ \t]*\\([0-9]+\\)" 1 2 3)
450
451 ;; This seems to be superfluous because the first pattern matches it.
452 ;; ;; GNU messages with program name and optional column number.
453 ;; ("[a-zA-Z]?:?[^0-9 \n\t:]+[^ \n\t:]*:[ \t]*\\([^ \n\t:]+\\):\
454 ;;\\([0-9]+\\):\\(\\([0-9]+\\)[: \t]\\)?" 1 2 4)
455
456 ;; Cray C compiler error messages
457 ("\\(cc\\| cft\\)-[0-9]+ c\\(c\\|f77\\): ERROR \\([^,\n]+, \\)* File = \
458 \\([^,\n]+\\), Line = \\([0-9]+\\)" 4 5)
459
460 ;; IBM C/C++ Tools 2.01:
461 ;; foo.c(2:0) : informational EDC0804: Function foo is not referenced.
462 ;; foo.c(3:8) : warning EDC0833: Implicit return statement encountered.
463 ;; foo.c(5:5) : error EDC0350: Syntax error.
464 ("\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) : " 1 2 3)
465
466 ;; IAR Systems C Compiler:
467 ;; "foo.c",3 Error[32]: Error message
468 ;; "foo.c",3 Warning[32]: Error message
469 ("\"\\(.*\\)\",\\([0-9]+\\)\\s-+\\(Error\\|Warning\\)\\[[0-9]+\\]:" 1 2)
470
471 ;; Sun ada (VADS, Solaris):
472 ;; /home3/xdhar/rcds_rc/main.a, line 361, char 6:syntax error: "," inserted
473 ("\\([^, \n\t]+\\), line \\([0-9]+\\), char \\([0-9]+\\)[:., \(-]" 1 2 3)
474
475 ;; Perl -w:
476 ;; syntax error at automake line 922, near "':'"
477 ;; Perl debugging traces
478 ;; store::odrecall('File_A', 'x2') called at store.pm line 90
479 (".* at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 1 2)
480
481 ;; Oracle pro*c:
482 ;; Semantic error at line 528, column 5, file erosacqdb.pc:
483 ("Semantic error at line \\([0-9]+\\), column \\([0-9]+\\), file \\(.*\\):"
484 3 1 2)
485
486 ;; EPC F90 compiler:
487 ;; Error 24 at (2:progran.f90) : syntax error
488 ("Error [0-9]+ at (\\([0-9]*\\):\\([^)\n]+\\))" 2 1)
489
490 ;; SGI IRIX MipsPro 7.3 compilers:
491 ;; cc-1070 cc: ERROR File = linkl.c, Line = 38
492 (".*: ERROR File = \\(.+\\), Line = \\([0-9]+\\)" 1 2)
493 (".*: WARNING File = \\(.+\\), Line = \\([0-9]+\\)" 1 2)
494
495 ;; Sun F90 error messages:
496 ;; cf90-113 f90comp: ERROR NSE, File = Hoved.f90, Line = 16, Column = 3
497 (".* ERROR [a-zA-Z0-9 ]+, File = \\(.+\\), Line = \\([0-9]+\\), Column = \\([0-9]+\\)"
498 1 2 3)
499
500 ;; RXP - GPL XML validator at http://www.cogsci.ed.ac.uk/~richard/rxp.html:
501 ;; Error: Mismatched end tag: expected </geroup>, got </group>
502 ;; in unnamed entity at line 71 char 8 of file:///home/reto/test/group.xml
503 ("Error:.*\n.* line \\([0-9]+\\) char \\([0-9]+\\) of file://\\(.+\\)"
504 3 1 2)
505 ;; Warning: Start tag for undeclared element geroup
506 ;; in unnamed entity at line 4 char 8 of file:///home/reto/test/group.xml
507 ("Warning:.*\n.* line \\([0-9]+\\) char \\([0-9]+\\) of file://\\(.+\\)"
508 3 1 2)
509 )
510
511 "Alist that specifies how to match errors in compiler output.
512 Each elt has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX FILE-FORMAT...])
513 If REGEXP matches, the FILE-IDX'th subexpression gives the file name, and
514 the LINE-IDX'th subexpression gives the line number. If COLUMN-IDX is
515 given, the COLUMN-IDX'th subexpression gives the column number on that line.
516 If any FILE-FORMAT is given, each is a format string to produce a file name to
517 try; %s in the string is replaced by the text matching the FILE-IDX'th
518 subexpression.")
519
520 (defvar compilation-enter-directory-regexp-alist
521 '(
522 ;; Matches lines printed by the `-w' option of GNU Make.
523 (".*: Entering directory `\\(.*\\)'$" 1)
524 )
525 "Alist specifying how to match lines that indicate a new current directory.
526 Note that the match is done at the beginning of lines.
527 Each elt has the form (REGEXP IDX).
528 If REGEXP matches, the IDX'th subexpression gives the directory name.
529
530 The default value matches lines printed by the `-w' option of GNU Make.")
531
532 (defvar compilation-leave-directory-regexp-alist
533 '(
534 ;; Matches lines printed by the `-w' option of GNU Make.
535 (".*: Leaving directory `\\(.*\\)'$" 1)
536 )
537 "Alist specifying how to match lines that indicate restoring current directory.
538 Note that the match is done at the beginning of lines.
539 Each elt has the form (REGEXP IDX).
540 If REGEXP matches, the IDX'th subexpression gives the name of the directory
541 being moved from. If IDX is nil, the last directory entered \(by a line
542 matching `compilation-enter-directory-regexp-alist'\) is assumed.
543
544 The default value matches lines printed by the `-w' option of GNU Make.")
545
546 (defvar compilation-file-regexp-alist
547 '(
548 ;; This matches entries with date time year file-name: like
549 ;; Thu May 14 10:46:12 1992 mom3.p:
550 ("\\w\\w\\w \\w\\w\\w +[0-9]+ [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9] \\(.*\\):$" 1)
551 )
552 "Alist specifying how to match lines that indicate a new current file.
553 Note that the match is done at the beginning of lines.
554 Each elt has the form (REGEXP IDX).
555 If REGEXP matches, the IDX'th subexpression gives the file name. This is
556 used with compilers that don't indicate file name in every error message.")
557
558 ;; There is no generally useful regexp that will match non messages, but
559 ;; in special cases there might be one. The lines that are not matched by
560 ;; a regexp take much longer time than the ones that are recognized so if
561 ;; you have same regexeps here, parsing is faster.
562 (defvar compilation-nomessage-regexp-alist
563 '(
564 )
565 "Alist specifying how to match lines that have no message.
566 Note that the match is done at the beginning of lines.
567 Each elt has the form (REGEXP). This alist is by default empty, but if
568 you have some good regexps here, the parsing of messages will be faster.")
569
570 (defcustom compilation-error-screen-columns t
571 "*If non-nil, column numbers in error messages are screen columns.
572 Otherwise they are interpreted as character positions, with
573 each character occupying one column.
574 The default is to use screen columns, which requires that the compilation
575 program and Emacs agree about the display width of the characters,
576 especially the TAB character."
577 :type 'boolean
578 :group 'compilation
579 :version "20.4")
580
581 (defcustom compilation-read-command t
582 "*Non-nil means \\[compile] reads the compilation command to use.
583 Otherwise, \\[compile] just uses the value of `compile-command'."
584 :type 'boolean
585 :group 'compilation)
586
587 ;;;###autoload
588 (defcustom compilation-ask-about-save t
589 "*Non-nil means \\[compile] asks which buffers to save before compiling.
590 Otherwise, it saves all modified buffers without asking."
591 :type 'boolean
592 :group 'compilation)
593
594 ;; Note: the character class after the optional drive letter does not
595 ;; include a space to support file names with blanks.
596 (defvar grep-regexp-alist
597 '(("\\([a-zA-Z]?:?[^:(\t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 2))
598 "Regexp used to match grep hits. See `compilation-error-regexp-alist'.")
599
600 (defvar grep-program
601 ;; Currently zgrep has trouble. It runs egrep instead of grep,
602 ;; and it doesn't pass along long options right.
603 "grep"
604 ;; (if (equal (condition-case nil ; in case "zgrep" isn't in exec-path
605 ;; (call-process "zgrep" nil nil nil
606 ;; "foo" null-device)
607 ;; (error nil))
608 ;; 1)
609 ;; "zgrep"
610 ;; "grep")
611 "The default grep program for `grep-command' and `grep-find-command'.
612 This variable's value takes effect when `grep-compute-defaults' is called.")
613
614 (defvar find-program "find"
615 "The default find program for `grep-find-command'.
616 This variable's value takes effect when `grep-compute-defaults' is called.")
617
618 (defvar grep-find-use-xargs nil
619 "Whether \\[grep-find] uses the `xargs' utility by default.
620
621 If nil, it uses `find -exec'; if `gnu', it uses `find -print0' and `xargs -0';
622 if not nil and not `gnu', it uses `find -print' and `xargs'.
623
624 This variable's value takes effect when `grep-compute-defaults' is called.")
625
626 ;;;###autoload
627 (defcustom compilation-search-path '(nil)
628 "*List of directories to search for source files named in error messages.
629 Elements should be directory names, not file names of directories.
630 nil as an element means to try the default directory."
631 :type '(repeat (choice (const :tag "Default" nil)
632 (string :tag "Directory")))
633 :group 'compilation)
634
635 (defcustom compile-command "make -k "
636 "*Last shell command used to do a compilation; default for next compilation.
637
638 Sometimes it is useful for files to supply local values for this variable.
639 You might also use mode hooks to specify it in certain modes, like this:
640
641 (add-hook 'c-mode-hook
642 (lambda ()
643 (unless (or (file-exists-p \"makefile\")
644 (file-exists-p \"Makefile\"))
645 (set (make-local-variable 'compile-command)
646 (concat \"make -k \"
647 (file-name-sans-extension buffer-file-name))))))"
648 :type 'string
649 :group 'compilation)
650
651 (defvar compilation-directory-stack nil
652 "Stack of previous directories for `compilation-leave-directory-regexp'.
653 The last element is the directory the compilation was started in.")
654
655 (defvar compilation-exit-message-function nil "\
656 If non-nil, called when a compilation process dies to return a status message.
657 This should be a function of three arguments: process status, exit status,
658 and exit message; it returns a cons (MESSAGE . MODELINE) of the strings to
659 write into the compilation buffer, and to put in its mode line.")
660
661 ;; History of compile commands.
662 (defvar compile-history nil)
663 ;; History of grep commands.
664 (defvar grep-history nil)
665 (defvar grep-find-history nil)
666
667 (defun compilation-mode-font-lock-keywords ()
668 "Return expressions to highlight in Compilation mode."
669 (nconc
670 ;;
671 ;; Compiler warning/error lines.
672 (mapcar (function
673 (lambda (item)
674 ;; Prepend "^", adjusting FILE-IDX and LINE-IDX accordingly.
675 (let ((file-idx (nth 1 item))
676 (line-idx (nth 2 item))
677 (col-idx (nth 3 item))
678 keyword)
679 (when (numberp col-idx)
680 (setq keyword
681 (cons (list (1+ col-idx) 'font-lock-type-face nil t)
682 keyword)))
683 (when (numberp line-idx)
684 (setq keyword
685 (cons (list (1+ line-idx) 'font-lock-variable-name-face)
686 keyword)))
687 (when (numberp file-idx)
688 (setq keyword
689 (cons (list (1+ file-idx) 'font-lock-warning-face)
690 keyword)))
691 (cons (concat "^\\(" (nth 0 item) "\\)") keyword))))
692 compilation-error-regexp-alist)
693 (list
694 ;;
695 ;; Compiler output lines. Recognize `make[n]:' lines too.
696 '("^\\([A-Za-z_0-9/\.+-]+\\)\\(\\[\\([0-9]+\\)\\]\\)?[ \t]*:"
697 (1 font-lock-function-name-face) (3 font-lock-comment-face nil t)))
698 ))
699
700 ;;;###autoload
701 (defun compile (command)
702 "Compile the program including the current buffer. Default: run `make'.
703 Runs COMMAND, a shell command, in a separate process asynchronously
704 with output going to the buffer `*compilation*'.
705
706 You can then use the command \\[next-error] to find the next error message
707 and move to the source code that caused it.
708
709 Interactively, prompts for the command if `compilation-read-command' is
710 non-nil; otherwise uses `compile-command'. With prefix arg, always prompts.
711
712 To run more than one compilation at once, start one and rename the
713 \`*compilation*' buffer to some other name with \\[rename-buffer].
714 Then start the next one.
715
716 The name used for the buffer is actually whatever is returned by
717 the function in `compilation-buffer-name-function', so you can set that
718 to a function that generates a unique name."
719 (interactive
720 (if (or compilation-read-command current-prefix-arg)
721 (list (read-from-minibuffer "Compile command: "
722 (eval compile-command) nil nil
723 '(compile-history . 1)))
724 (list (eval compile-command))))
725 (unless (equal command (eval compile-command))
726 (setq compile-command command))
727 (save-some-buffers (not compilation-ask-about-save) nil)
728 (compile-internal command "No more errors"))
729
730 ;; run compile with the default command line
731 (defun recompile ()
732 "Re-compile the program including the current buffer.
733 If this is run in a compilation-mode buffer, re-use the arguments from the
734 original use. Otherwise, it recompiles using `compile-command'."
735 (interactive)
736 (save-some-buffers (not compilation-ask-about-save) nil)
737 (apply 'compile-internal (or compilation-arguments
738 `(,(eval compile-command) "No more errors"))))
739
740 (defun grep-process-setup ()
741 "Set up `compilation-exit-message-function' for `grep'."
742 (set (make-local-variable 'compilation-exit-message-function)
743 (lambda (status code msg)
744 (if (eq status 'exit)
745 (cond ((zerop code)
746 '("finished (matches found)\n" . "matched"))
747 ((= code 1)
748 '("finished with no matches found\n" . "no match"))
749 (t
750 (cons msg code)))
751 (cons msg code)))))
752 750
753 ;;;###autoload 751 ;;;###autoload
754 (defun grep (command-args) 752 (defun grep (command-args)
755 "Run grep, with user-specified args, and collect output in a buffer. 753 "Run grep, with user-specified args, and collect output in a buffer.
756 While grep runs asynchronously, you can use \\[next-error] (M-x next-error), 754 While grep runs asynchronously, you can use \\[next-error] (M-x next-error),