mirrored from git://git.sv.gnu.org/emacs.git
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
compile.el
3413 lines (3099 loc) · 142 KB
/
compile.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; compile.el --- run compiler as inferior of Emacs, parse error messages -*- lexical-binding:t -*-
;; Copyright (C) 1985-1987, 1993-1999, 2001-2024 Free Software
;; Foundation, Inc.
;; Authors: Roland McGrath <[email protected]>,
;; Daniel Pfeiffer <[email protected]>
;; Maintainer: [email protected]
;; Keywords: tools, processes
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This package provides the compile facilities documented in the Emacs user's
;; manual.
;;; Code:
(eval-when-compile (require 'cl-lib))
(require 'tool-bar)
(require 'comint)
(require 'text-property-search)
(defgroup compilation nil
"Run compiler as inferior of Emacs, parse error messages."
:group 'tools
:group 'processes)
;;;###autoload
(defcustom compilation-mode-hook nil
"List of hook functions run by `compilation-mode'."
:type 'hook)
;;;###autoload
(defcustom compilation-start-hook nil
"Hook run after starting a new compilation process.
The hook is run with one argument, the new process."
:type 'hook)
;;;###autoload
(defcustom compilation-window-height nil
"Number of lines in a compilation window.
If nil, use Emacs default."
:type '(choice (const :tag "Default" nil)
integer))
(defcustom compilation-transform-file-match-alist
'(("/bin/[a-z]*sh\\'" nil))
"Alist of regexp/replacements to alter file names in compilation errors.
If the replacement is nil, the file will not be considered an
error after all. If not nil, it should be a regexp replacement
string."
:type '(repeat (list regexp (choice (const :tag "No replacement" nil)
string)))
:version "27.1")
(defvar compilation-filter-hook nil
"Hook run after `compilation-filter' has inserted a string into the buffer.
It is called with the variable `compilation-filter-start' bound
to the position of the start of the inserted text, and point at
its end.
If Emacs lacks asynchronous process support, this hook is run
after `call-process' inserts the grep output into the buffer.")
(defvar compilation-filter-start nil
"Position of the start of the text inserted by `compilation-filter'.
This is bound before running `compilation-filter-hook'.")
(defcustom compilation-hidden-output nil
"Regexp to match output from the compilation that should be hidden.
This can also be a list of regexps.
The text matched by this variable will be made invisible, which
means that it'll still be present in the buffer, so that
navigation commands (for instance, `next-error') can still make
use of the hidden text to determine the current directory and the
like.
For instance, to hide the verbose output from recursive
makefiles, you can say something like:
(setq compilation-hidden-output
\\='(\"^make[^\n]+\n\"))"
:type '(choice regexp
(repeat regexp))
:version "29.1")
(defvar compilation-first-column 1
"This is how compilers number the first column, usually 1 or 0.
If this is buffer-local in the destination buffer, Emacs obeys
that value, otherwise it uses the value in the *compilation*
buffer. This enables a major mode to specify its own value.")
(defvar compilation-parse-errors-filename-function #'identity
"Function to call to post-process filenames while parsing error messages.
It takes one arg FILENAME which is the name of a file as found
in the compilation output, and should return a transformed file name
or a buffer, the one which was compiled.")
;; Note: the compilation-parse-errors-filename-function need not save the
;; match data.
;;;###autoload
(defvar compilation-process-setup-function #'ignore
"Function to call to customize the compilation process.
This function is called immediately before the compilation process is
started. It can be used to set any variables or functions that are used
while processing the output of the compilation process.")
;;;###autoload
(defvar compilation-buffer-name-function #'compilation--default-buffer-name
"Function to compute the name of a compilation buffer.
The function receives one argument, the name of the major mode of the
compilation buffer. It should return a string.
By default, it returns `(concat \"*\" (downcase name-of-mode) \"*\")'.")
;;;###autoload
(defvar compilation-finish-functions nil
"Functions to call when a compilation process finishes.
Each function is called with two arguments: the compilation buffer,
and a string describing how the process finished.")
(defvar compilation-in-progress nil
"List of compilation processes now running.")
(or (assq 'compilation-in-progress mode-line-modes)
(add-to-list 'mode-line-modes
(list 'compilation-in-progress
(propertize "[Compiling] "
'help-echo "Compiling; mouse-2: Goto Buffer"
'mouse-face 'mode-line-highlight
'local-map
(make-mode-line-mouse-map
'mouse-2
#'compilation-goto-in-progress-buffer)))))
(defun compilation-goto-in-progress-buffer ()
"Switch to the compilation buffer."
(interactive)
(cond
((> (length compilation-in-progress) 1)
(switch-to-buffer (completing-read
"Several compilation buffers; switch to: "
(mapcar
(lambda (process)
(buffer-name (process-buffer process)))
compilation-in-progress)
nil t)))
(compilation-in-progress
(switch-to-buffer (process-buffer (car compilation-in-progress))))
(t
(error "No ongoing compilations"))))
(defvar compilation-error "error"
"Stem of message to print when no matches are found.")
(defvar compilation-arguments nil
"Arguments that were given to `compilation-start'.")
(defvar compilation-num-errors-found 0)
(defvar compilation-num-warnings-found 0)
(defvar compilation-num-infos-found 0)
(defvar compilation-mode-line-errors
'(" [" (:propertize (:eval (int-to-string compilation-num-errors-found))
face compilation-error
help-echo "Number of errors so far")
" " (:propertize (:eval (int-to-string compilation-num-warnings-found))
face compilation-warning
help-echo "Number of warnings so far")
" " (:propertize (:eval (int-to-string compilation-num-infos-found))
face compilation-info
help-echo "Number of informational messages so far")
"]"))
(put 'compilation-mode-line-errors 'risky-local-variable t)
;; If you make any changes to `compilation-error-regexp-alist-alist',
;; be sure to run the ERT test in test/lisp/progmodes/compile-tests.el.
;; emacs -batch -l compile-tests.el -f ert-run-tests-batch-and-exit
(defvar compilation-error-regexp-alist-alist
(eval-when-compile
;; The order of this list is the default order of items in
;; `compilation-error-regexp-alist' which is also the matching order,
;; so don't add things in alphabetic order just out of habit.
;; FIXME: We should sort it by frequency (less often used ones in the back),
;; but individual patterns also have their own partial order.
`((absoft
"^\\(?:[Ee]rror on \\|[Ww]arning on\\( \\)\\)?[Ll]ine[ \t]+\\([0-9]+\\)[ \t]+\
of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil (1))
(ada
"\\(warning: .*\\)? at \\([^ \n]+\\):\\([0-9]+\\)$" 2 3 nil (1))
(aix
" in line \\([0-9]+\\) of file \\([^ \n]+[^. \n]\\)\\.? " 2 1)
;; Checkstyle task may report its own severity level: "[checkstyle] [ERROR] ..."
;; (see AuditEventDefaultFormatter.java in checkstyle sources).
(ant
"^[ \t]*\\(?:\\[[^] \n]+\\][ \t]*\\)\\{1,2\\}\\(\\(?:[A-Za-z]:\\)?[^: \n]+\\):\
\\([0-9]+\\):\\(?:\\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\):\\)?\\( warning\\)?"
1 (2 . 4) (3 . 5) (6))
(bash
"^\\([^: \n\t]+\\): line \\([0-9]+\\):" 1 2)
(borland
"^\\(?:Error\\|Warnin\\(g\\)\\) \\(?:[FEW][0-9]+ \\)?\
\\([a-zA-Z]?:?[^:( \t\n]+\\)\
\\([0-9]+\\)\\(?:[) \t]\\|:[^0-9\n]\\)" 2 3 nil (1))
(python-tracebacks-and-caml
"^[ \t]*File \\(\"?\\)\\([^,\" \n\t<>]+\\)\\1, lines? \\([0-9]+\\)-?\\([0-9]+\\)?\\(?:$\\|,\
\\(?: characters? \\([0-9]+\\)-?\\([0-9]+\\)?:\\)?\\([ \n]Warning\\(?: [0-9]+\\)?:\\)?\\)"
2 (3 . 4) (5 . 6) (7))
(cmake
"^CMake \\(?:Error\\|\\(Warning\\)\\) at \\(.*\\):\\([1-9][0-9]*\\) ([^)]+):$"
2 3 nil (1))
(cmake-info
"^ \\(?: \\*\\)?\\(.*\\):\\([1-9][0-9]*\\) ([^)]+)$"
1 2 nil 0)
(comma
"^\"\\([^,\" \n\t]+\\)\", line \\([0-9]+\\)\
\\(?:[(. pos]+\\([0-9]+\\))?\\)?[:.,; (-]\\( warning:\\|[-0-9 ]*(W)\\)?" 1 2 3 (4))
(msft
;; Must be before edg-1, so that MSVC's longer messages are
;; considered before EDG.
;; The message may be a "warning", "error", or "fatal error" with
;; an error code, or "see declaration of" without an error code.
"^ *\\([0-9]+>\\)?\\(\\(?:[a-zA-Z]:\\)?[^ :(\t\n][^:(\t\n]*\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?) ?\
: \\(?:see declaration\\|\\(?:warnin\\(g\\)\\|[a-z ]+\\) C[0-9]+:\\)"
2 3 4 (5))
(edg-1
"^\\([^ \n]+\\)(\\([0-9]+\\)): \\(?:error\\|warnin\\(g\\)\\|remar\\(k\\)\\)"
1 2 nil (3 . 4))
(edg-2
"at line \\([0-9]+\\) of \"\\([^ \n]+\\)\"$"
2 1 nil 0)
(epc
"^Error [0-9]+ at (\\([0-9]+\\):\\([^)\n]+\\))" 2 1)
(ftnchek
"\\(^Warning .*\\)? line[ \n]\\([0-9]+\\)[ \n]\\(?:col \\([0-9]+\\)[ \n]\\)?file \\([^ :;\n]+\\)"
4 2 3 (1))
;; Introduced in Kotlin 1.8 and current as of Kotlin 2.0.
;; Emitted by `GradleStyleMessagerRenderer' in Kotlin sources.
(gradle-kotlin
,(rx bol
(| (group "w") ; 1: warning
(group (in "iv")) ; 2: info
"e") ; error
": "
"file://"
(group ; 3: file
(? (in "A-Za-z") ":")
(+ (not (in "\n:"))))
":"
(group (+ digit)) ; 4: line
":"
(group (+ digit)) ; 5: column
" ")
3 4 5 (1 . 2))
;; Obsoleted in Kotlin 1.8 Beta, released on Nov 15, 2022.
;; See commit `93a0cdbf973' in Kotlin Git repository.
(gradle-kotlin-legacy
,(rx bol
(| (group "w") ; 1: warning
(group (in "iv")) ; 2: info
"e") ; error
": "
(group ; 3: file
(? (in "A-Za-z") ":")
(+ (not (in "\n:"))))
": ("
(group (+ digit)) ; 4: line
", "
(group (+ digit)) ; 5: column
"): ")
3 4 5 (1 . 2))
(gradle-android
,(rx bol (* " ") "ERROR:"
(group-n 1 ; file
(+ (not (in ":\n"))))
":"
(group-n 2 (+ digit)) ; line
": ")
1 2)
(iar
"^\"\\(.*\\)\",\\([0-9]+\\)\\s-+\\(?:Error\\|Warnin\\(g\\)\\)\\[[0-9]+\\]:"
1 2 nil (3))
(ibm
"^\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) :\
\\(?:warnin\\(g\\)\\|informationa\\(l\\)\\)?" 1 2 3 (4 . 5))
;; fixme: should be `mips'
(irix
"^[-[:alnum:]_/ ]+: \\(?:\\(?:[sS]evere\\|[eE]rror\\|[wW]arnin\\(g\\)\\|[iI]nf\\(o\\)\\)[0-9 ]*: \\)?\
\\([^,\" \n\t]+\\)\\(?:, line\\|:\\) \\([0-9]+\\):" 3 4 nil (1 . 2))
(java
"^\\(?:[ \t]+at \\|==[0-9]+== +\\(?:at\\|b\\(y\\)\\)\\).+(\\([^()\n]+\\):\\([0-9]+\\))$" 2 3 nil (1))
(javac
,(rx bol
(group ; file
(? (in "A-Za-z") ":")
(+ (not (in "\n:"))))
":"
(group (+ (in "0-9"))) ; line number
": "
(? (group "warning: ")) ; type (optional)
(* nonl) "\n" ; message
(* nonl) "\n" ; source line containing error
(* " ") "^" ; caret line; ^ marks error
eol)
1 2
,#'current-column
(3))
(jikes-file
"^\\(?:Found\\|Issued\\) .* compiling \"\\(.+\\)\":$" 1 nil nil 0)
(maven
;; Maven is a popular free software build tool for Java.
,(rx bol
;; It is unclear whether the initial [type] tag is always present.
(? "["
(or "ERROR" (group-n 1 "WARNING") (group-n 2 "INFO"))
"] ")
(group-n 3 ; File
(not (any "\n ["))
(* (or (not (any "\n :"))
(: " " (not (any "\n/-")))
(: ":" (not (any "\n ["))))))
":["
(group-n 4 (+ digit)) ; Line
","
(group-n 5 (+ digit)) ; Column
"] ")
3 4 5 (1 . 2))
(jikes-line
"^ *\\([0-9]+\\)\\.[ \t]+.*\n +\\(<-*>\n\\*\\*\\* \\(?:Error\\|Warnin\\(g\\)\\)\\)"
nil 1 nil 2 0
(2 (compilation-face '(3))))
(clang-include
,(rx bol "In file included from "
(group (+ (not (any ?\n ?:)))) ?:
(group (+ (any (?0 . ?9)))) ?:
eol)
1 2 nil 0)
(gcc-include
"^\\(?:In file included \\| \\|\t\\)from \
\\([0-9]*[^0-9\n]\\(?:[^\n :]\\| [^-/\n]\\|:[^ \n]\\)*?\\):\
\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?\\(?:\\([:,]\\|$\\)\\)?"
1 2 3 (nil . 4))
(ruby-Test::Unit
"^ [[ ]?\\([^ (].*\\):\\([1-9][0-9]*\\)\\(\\]\\)?:in " 1 2)
;; Tested with Lua 5.1, 5.2, 5.3, 5.4, and LuaJIT 2.1.
(lua
,(rx bol
(+? (not (in "\t\n")))
": "
(group (+? (not (in "\t\n"))))
":"
(group (+ (in "0-9")))
": "
(+ nonl)
"\nstack traceback:\n\t")
1 2 nil 2 1)
(lua-stack
,(rx bol "\t"
(| "[C]:"
(: (group (+? (not (in "\t\n"))))
":"
(? (group (+ (in "0-9")))
":")))
" in ")
1 2 nil 0 1)
(gmake
;; Set GNU make error messages as INFO level.
;; It starts with the name of the make program which is variable,
;; so don't try to match it.
": \\*\\*\\* \\[\\(\\(.+?\\):\\([0-9]+\\): .+\\)\\]" 2 3 nil 0 1)
(gnu
;; The `gnu' message syntax is
;; [PROGRAM:]FILE:LINE[-ENDLINE]:[COL[-ENDCOL]:] MESSAGE
;; or
;; [PROGRAM:]FILE:LINE[.COL][-ENDLINE[.ENDCOL]]: MESSAGE
,(rx
bol
;; Match an optional program name which is used for
;; non-interactive programs other than compilers (e.g. the
;; "jade:" entry in compilation.txt).
(? (| (: alpha (+ (in ?. ?- alnum)) ":" (? " "))
;; Skip indentation generated by GCC's -fanalyzer.
(: (+ " ") "|")))
;; File name group.
(group-n 1
;; Avoid matching the file name as a program in the pattern
;; above by disallowing file names entirely composed of digits.
;; Do not allow file names beginning with a space.
(| (not (in "0-9" "\n\t "))
(: (+ (in "0-9"))
(not (in "0-9" "\n"))))
;; A file name can be composed of any non-newline char, but
;; rule out some valid but unlikely cases, such as a trailing
;; space or a space followed by a -, or a colon followed by a
;; space.
(*? (| (not (in "\n :"))
(: " " (not (in ?- "/\n")))
(: ":" (not (in " \n"))))))
":" (? " ")
;; Line number group.
(group-n 2 (+ (in "0-9")))
(? (| (: "-"
(group-n 4 (+ (in "0-9"))) ; ending line
(? "." (group-n 5 (+ (in "0-9"))))) ; ending column
(: (in ".:")
(group-n 3 (+ (in "0-9"))) ; starting column
(? "-"
(? (group-n 4 (+ (in "0-9"))) ".") ; ending line
(group-n 5 (+ (in "0-9"))))))) ; ending column
":"
(| (: (* " ")
(group-n 6 (| "FutureWarning"
"RuntimeWarning"
"Warning" "warning"
"W:")))
(: (* " ")
(group-n 7
(| (| "Info" "info"
"Information" "information"
"Informational" "informational"
"I:"
"instantiated from"
"required from"
"Note" "note")
(: "[ skipping " (+ nonl) " ]"))))
(: (* " ")
(| "Error" "error"))
;; Avoid matching time stamps on the form "HH:MM:SS" where
;; MM is interpreted as a line number by trying to rule out
;; messages where the text after the line number starts with
;; a 2-digit number.
(: (? (in "0-9"))
(| (not (in "0-9\n"))
eol))
(: (in "0-9") (in "0-9") (in "0-9"))))
1 (2 . 4) (3 . 5) (6 . 7))
(cucumber
,(rx (| (: bol
(| (: "cucumber" (? " -p " (+ (not space))))
" "))
"#")
" "
(group (not "(") (* nonl)) ; file
":"
(group (in "1-9") (* (in "0-9")))) ; line
1 2)
(lcc
"^\\(?:E\\|\\(W\\)\\), \\([^(\n]+\\)(\\([0-9]+\\),[ \t]*\\([0-9]+\\)"
2 3 4 (1))
(makepp
"^makepp\\(?:\\(?:: warning\\(:\\).*?\\|\\(: Scanning\\|: [LR]e?l?oading makefile\\|: Imported\\|log:.*?\\) \\|: .*?\\)\
`\\(\\(\\S +?\\)\\(?::\\([0-9]+\\)\\)?\\)['(]\\)"
4 5 nil (1 . 2) 3
(0 (progn (save-match-data
(compilation-parse-errors
(match-end 0) (line-end-position)
`("`\\(\\(\\S +?\\)\\(?::\\([0-9]+\\)\\)?\\)['(]"
2 3 nil
,(cond ((match-end 1) 1) ((match-end 2) 0) (t 2))
1)))
(end-of-line)
nil)))
;; Should be lint-1, lint-2 (SysV lint)
(mips-1
" (\\([0-9]+\\)) in \\([^ \n]+\\)" 2 1)
(mips-2
" in \\([^()\n ]+\\)(\\([0-9]+\\))$" 1 2)
(omake
;; "omake -P" reports "file foo changed"
;; (useful if you do "cvs up" and want to see what has changed)
"^\\*\\*\\* omake: file \\(.*\\) changed" 1 nil nil nil nil
;; FIXME-omake: This tries to prevent reusing pre-existing markers
;; for subsequent messages, since those messages's line numbers
;; are about another version of the file.
(0 (progn (compilation--flush-file-structure (match-string 1))
nil)))
(oracle
"^\\(?:Semantic error\\|Error\\|PCC-[0-9]+:\\).* line \\([0-9]+\\)\
\\(?:\\(?:,\\| at\\)? column \\([0-9]+\\)\\)?\
\\(?:,\\| in\\| of\\)? file \\(.*?\\):?$"
3 1 2)
;; "during global destruction": This comes out under "use
;; warnings" in recent perl when breaking circular references
;; during program or thread exit.
(perl
" at \\([^ \n]+\\) line \\([0-9]+\\)\\(?:[,.]\\|$\\| \
during global destruction\\.$\\)" 1 2)
(php
"\\(?:Parse\\|Fatal\\) error: \\(.*\\) in \\(.*\\) on line \\([0-9]+\\)"
2 3 nil nil)
(rxp
"^\\(?:Error\\|Warnin\\(g\\)\\):.*\n.* line \\([0-9]+\\) char\
\\([0-9]+\\) of file://\\(.+\\)"
4 2 3 (1))
(shellcheck
"^In \\(.+\\) line \\([0-9]+\\):" 1 2)
(sparc-pascal-file
"^\\w\\w\\w \\w\\w\\w +[0-3]?[0-9] +[0-2][0-9]:[0-5][0-9]:[0-5][0-9]\
[12][09][0-9][0-9] +\\(.*\\):$"
1 nil nil 0)
(sparc-pascal-line
"^\\(\\(?:E\\|\\(w\\)\\) +[0-9]+\\) line \\([0-9]+\\) - "
nil 3 nil (2) nil (1 (compilation-face '(2))))
(sparc-pascal-example
"^ +\\([0-9]+\\) +.*\n\\(\\(?:e\\|\\(w\\)\\) [0-9]+\\)-+"
nil 1 nil (3) nil (2 (compilation-face '(3))))
(sun
": \\(?:ERROR\\|WARNIN\\(G\\)\\|REMAR\\(K\\)\\) \\(?:[[:alnum:] ]+, \\)?\
File = \\(.+\\), Line = \\([0-9]+\\)\\(?:, Column = \\([0-9]+\\)\\)?"
3 4 5 (1 . 2))
(sun-ada
"^\\([^, \n\t]+\\), line \\([0-9]+\\), char \\([0-9]+\\)[:., (-]" 1 2 3)
(watcom
"^[ \t]*\\(\\(?:[a-zA-Z]:\\)?[^ :(\t\n][^:(\t\n]*\\)(\\([0-9]+\\)): ?\
\\(?:\\(Error! E[0-9]+\\)\\|\\(Warning! W[0-9]+\\)\\):"
1 2 nil (4))
(4bsd
"\\(?:^\\|:: \\|\\S ( \\)\\(/[^ \n\t()]+\\)(\\([0-9]+\\))\
\\(?:: \\(warning:\\)?\\|$\\| ),\\)" 1 2 nil (3))
(gcov-file
"^ *-: *\\(0\\):Source:\\(.+\\)$"
2 1 nil 0 nil)
(gcov-header
"^ *-: *\\(0\\):\\(?:Object\\|Graph\\|Data\\|Runs\\|Programs\\):.+$"
nil 1 nil 0 nil)
;; Underlines over all lines of gcov output are too uncomfortable to read.
;; However, hyperlinks embedded in the lines are useful.
;; So I put default face on the lines; and then put
;; compilation-*-face by manually to eliminate the underlines.
;; The hyperlinks are still effective.
(gcov-nomark
"^ *-: *\\([1-9]\\|[0-9]\\{2,\\}\\):.*$"
nil 1 nil 0 nil
(0 'default)
(1 compilation-line-face))
(gcov-called-line
"^ *\\([0-9]+\\): *\\([0-9]+\\):.*$"
nil 2 nil 0 nil
(0 'default)
(1 compilation-info-face) (2 compilation-line-face))
(gcov-never-called
"^ *\\(#####\\): *\\([0-9]+\\):.*$"
nil 2 nil 2 nil
(0 'default)
(1 compilation-error-face) (2 compilation-line-face))
(perl--Pod::Checker
;; podchecker error messages, per Pod::Checker.
;; The style is from the Pod::Checker::poderror() function, eg.
;; *** ERROR: Spurious text after =cut at line 193 in file foo.pm
;;
;; Plus end_pod() can give "at line EOF" instead of a
;; number, so for that match "on line N" which is the
;; originating spot, eg.
;; *** ERROR: =over on line 37 without closing =back at line EOF in file bar.pm
;;
;; Plus command() can give both "on line N" and "at line N";
;; the latter is desired and is matched because the .* is
;; greedy.
;; *** ERROR: =over on line 1 without closing =back (at head1) at line 3 in file x.pod
;;
"^\\*\\*\\* \\(?:ERROR\\|\\(WARNING\\)\\).* \\(?:at\\|on\\) line \
\\([0-9]+\\) \\(?:.* \\)?in file \\([^ \t\n]+\\)"
3 2 nil (1))
(perl--Test
;; perl Test module error messages.
;; Style per the ok() function "$context", eg.
;; # Failed test 1 in foo.t at line 6
;;
"^# Failed test [0-9]+ in \\([^ \t\r\n]+\\) at line \\([0-9]+\\)"
1 2)
(perl--Test2
;; Or when comparing got/want values, with a "fail #n" if repeated
;; # Test 2 got: "xx" (t-compilation-perl-2.t at line 10)
;; # Test 3 got: "xx" (t-compilation-perl-2.t at line 10 fail #2)
;;
;; And under Test::Harness they're preceded by progress stuff with
;; \r and "NOK",
;; ... NOK 1# Test 1 got: "1234" (t/foo.t at line 46)
;;
"^\\(.*NOK.*\\)?# Test [0-9]+ got:.* (\\([^ \t\r\n]+\\) at line \
\\([0-9]+\\)\\( fail #[0-9]+\\)?)"
2 3)
(perl--Test::Harness
;; perl Test::Harness output, eg.
;; NOK 1# Test 1 got: "1234" (t/foo.t at line 46)
;;
;; Test::Harness is slightly designed for tty output, since
;; it prints CRs to overwrite progress messages, but if you
;; run it in with M-x compile this pattern can at least step
;; through the failures.
;;
"^.*NOK.* \\([^ \t\r\n]+\\) at line \\([0-9]+\\)"
1 2)
(weblint
;; The style comes from HTML::Lint::Error::as_string(), eg.
;; index.html (13:1) Unknown element <fdjsk>
;;
;; The pattern only matches filenames without spaces, since that
;; should be usual and should help reduce the chance of a false
;; match of a message from some unrelated program.
;;
;; This message style is quite close to the "ibm" entry which is
;; for IBM C, though that ibm bit doesn't put a space after the
;; filename.
;;
"^\\([^ \t\r\n(]+\\) (\\([0-9]+\\):\\([0-9]+\\)) "
1 2 3)
;; Guile compilation yields file-headers in the following format:
;;
;; In sourcefile.scm:
;;
;; We need to catch those, but we also need to be aware that Emacs
;; byte-compilation yields compiler headers in similar form of
;; those:
;;
;; In toplevel form:
;; In end of data:
;;
;; We want to catch the Guile file-headers but not the Emacs
;; byte-compilation headers, because that will cause next-error
;; and prev-error to break, because the files "toplevel form" and
;; "end of data" does not exist.
;;
;; To differentiate between these two cases, we require that the
;; file-match must always contain an extension.
;;
;; We should also only treat this as "info", not "error", because
;; we do not know what lines will follow.
(guile-file "^In \\(.+\\..+\\):\n" 1 nil nil 0)
(guile-line "^ *\\([0-9]+\\): *\\([0-9]+\\)" nil 1 2)
;; Typescript compilation prior to tsc version 2.7, "plain" format:
;; greeter.ts(30,12): error TS2339: Property 'foo' does not exist.
(typescript-tsc-plain
,(rx bol
(group (not (in " \t\n()")) ; 1: file
(* (not (in "\n()"))))
"("
(group (+ (in "0-9"))) ; 2: line
","
(group (+ (in "0-9"))) ; 3: column
"): error "
(+ (in "0-9A-Z")) ; error code
": ")
1 2 3 2)
;; Typescript compilation after tsc version 2.7, "pretty" format:
;; src/resources/document.ts:140:22 - error TS2362: something.
(typescript-tsc-pretty
,(rx bol
(group (not (in " \t\n()")) ; 1: file
(* (not (in "\n()"))))
":"
(group (+ (in "0-9"))) ; 2: line
":"
(group (+ (in "0-9"))) ; 3: column
" - error "
(+ (in "0-9A-Z")) ; error code
": ")
1 2 3 2)
))
"Alist of values for `compilation-error-regexp-alist'.")
(defcustom compilation-error-regexp-alist
;; Omit `omake' by default: its mere presence here triggers special processing
;; and modifies regexps for other rules (see `compilation-parse-errors'),
;; which may slow down matching (or even cause mismatches).
(delq 'omake (mapcar #'car compilation-error-regexp-alist-alist))
"Alist that specifies how to match errors in compiler output.
On GNU and Unix, any string is a valid filename, so these
matchers must make some common sense assumptions, which catch
normal cases. A shorter list will be lighter on resource usage.
Instead of an alist element, you can use a symbol, which is
looked up in `compilation-error-regexp-alist-alist'. You can see
the predefined symbols and their effects in the file
`etc/compilation.txt' (linked below if you are customizing this).
Each elt has the form (REGEXP FILE [LINE COLUMN TYPE HYPERLINK
HIGHLIGHT...]). If REGEXP matches, the FILE'th subexpression
gives the file name, and the LINE'th subexpression gives the line
number. The COLUMN'th subexpression gives the column number on
that line.
If FILE, LINE or COLUMN are nil or that index didn't match, that
information is not present on the matched line. In that case the
file name is assumed to be the same as the previous one in the
buffer, line number defaults to 1 and column defaults to
beginning of line's indentation.
FILE can also have the form (FILE FORMAT...), where the FORMATs
\(e.g. \"%s.c\") will be applied in turn to the recognized file
name, until a file of that name is found. Or FILE can also be a
function that returns (FILENAME) or (RELATIVE-FILENAME . DIRNAME).
In the former case, FILENAME may be relative or absolute, or it may
be a buffer.
LINE can also be of the form (LINE . END-LINE) meaning a range
of lines. COLUMN can also be of the form (COLUMN . END-COLUMN)
meaning a range of columns starting on LINE and ending on
END-LINE, if that matched.
LINE, END-LINE, COL, and END-COL can also be functions of no argument
that return the corresponding line or column number. They can assume REGEXP
has just been matched, and should correspondingly preserve this match data.
TYPE is 2 or nil for a real error or 1 for warning or 0 for info.
TYPE can also be of the form (WARNING . INFO). In that case this
will be equivalent to 1 if the WARNING'th subexpression matched
or else equivalent to 0 if the INFO'th subexpression matched,
or else equivalent to 2 if neither of them matched.
See `compilation-error-face', `compilation-warning-face',
`compilation-info-face' and `compilation-skip-threshold'.
What matched the HYPERLINK'th subexpression has `mouse-face' and
`compilation-message-face' applied. If this is nil, the text
matched by the whole REGEXP becomes the hyperlink.
Additional HIGHLIGHTs take the shape (SUBMATCH FACE), where
SUBMATCH is the number of a submatch and FACE is an expression
which evaluates to a face name (a symbol or string).
Alternatively, FACE can evaluate to a property list of the
form (face FACE PROP1 VAL1 PROP2 VAL2 ...), in which case all the
listed text properties PROP# are given values VAL# as well.
After identifying errors and warnings determined by this
variable, the `compilation-transform-file-match-alist' variable
is then consulted. It allows further transformations of the
matched file names, and weeding out false positives."
:type '(repeat (choice (symbol :tag "Predefined symbol")
(sexp :tag "Error specification")))
:link `(file-link :tag "example file"
,(expand-file-name "compilation.txt" data-directory)))
(defvar compilation-error-case-fold-search nil
"If non-nil, use case-insensitive matching of compilation errors.
If nil, matching is case-sensitive.
Compilation errors are given by the regexps in
`compilation-error-regexp-alist' and
`compilation-error-regexp-alist-alist'.
This variable should only be set for backward compatibility as a temporary
measure. The proper solution is to use a regexp that matches the
messages without case-folding.")
;;;###autoload(put 'compilation-directory 'safe-local-variable 'stringp)
(defvar compilation-directory nil
"Directory to restore to when doing `recompile'.")
(defvar compilation-directory-matcher
'("\\(?:Entering\\|Leavin\\(g\\)\\) directory [`']\\(.+\\)'$" (2 . 1))
"A list for tracking when directories are entered or left.
If nil, do not track directories, e.g. if all file names are absolute. The
first element is the REGEXP matching these messages. It can match any number
of variants, e.g. different languages. The remaining elements are all of the
form (DIR . LEAVE). If for any one of these the DIR'th subexpression
matches, that is a directory name. If LEAVE is nil or the corresponding
LEAVE'th subexpression doesn't match, this message is about going into another
directory. If it does match anything, this message is about going back to the
directory we were in before the last entering message. If you change this,
you may also want to change `compilation-page-delimiter'.")
(defvar compilation-page-delimiter
"^\\(?:\f\\|.*\\(?:Entering\\|Leaving\\) directory [`'].+'\n\\)+"
"Value of `page-delimiter' in Compilation mode.")
(defvar compilation-mode-font-lock-keywords
'(;; configure output lines.
("^[Cc]hecking \\(?:[Ff]or \\|[Ii]f \\|[Ww]hether \\(?:to \\)?\\)?\\(.+\\)\\.\\.\\. *\\(?:(cached) *\\)?\\(\\(yes\\(?: .+\\)?\\)\\|no\\|\\(.*\\)\\)$"
(1 font-lock-variable-name-face)
(2 (compilation-face '(4 . 3))))
;; Command output lines. Recognize `make[n]:' lines too.
("^\\([[:alnum:]_/.+-]+\\)\\(\\[\\([0-9]+\\)\\]\\)?[ \t]*:"
(1 font-lock-function-name-face) (3 compilation-line-face nil t))
(" --?o\\(?:utfile\\|utput\\)?[= ]\\(\\S +\\)" . 1)
("^Compilation \\(finished\\).*"
(0 '(face nil compilation-message nil help-echo nil mouse-face nil) t)
(1 compilation-info-face))
("^Compilation \\(exited abnormally\\|interrupt\\|killed\\|terminated\\|segmentation fault\\)\\(?:.*with code \\([0-9]+\\)\\)?.*"
(0 '(face nil compilation-message nil help-echo nil mouse-face nil) t)
(1 compilation-error-face)
(2 compilation-error-face nil t)))
"Additional things to highlight in Compilation mode.
This gets tacked on the end of the generated expressions.")
(defvar compilation-highlight-regexp t
"Regexp matching part of visited source lines to highlight temporarily.
Highlight entire line if t; don't highlight source lines if nil.")
(defvar compilation-highlight-overlay nil
"Overlay used to temporarily highlight compilation matches.")
(defcustom compilation-error-screen-columns t
"If non-nil, column numbers in error messages are screen columns.
Otherwise they are interpreted as character positions, with
each character occupying one column.
The default is to use screen columns, which requires that the compilation
program and Emacs agree about the display width of the characters,
especially the TAB character.
If this is buffer-local in the destination buffer, Emacs obeys
that value, otherwise it uses the value in the *compilation*
buffer. This enables a major mode to specify its own value."
:type 'boolean
:version "20.4")
(defcustom compilation-read-command t
"Non-nil means \\[compile] reads the compilation command to use.
Otherwise, \\[compile] just uses the value of `compile-command'.
Note that changing this to nil may be a security risk, because a
file might define a malicious `compile-command' as a file local
variable, and you might not notice. Therefore, `compile-command'
is considered unsafe if this variable is nil."
:type 'boolean)
(defcustom compilation-search-all-directories t
"Whether further upward directories should be used when searching a file.
When doing a parallel build, several files from different
directories can be compiled at the same time. This makes it
difficult to determine the base directory for a relative file
name in a compiler error or warning. If this variable is
non-nil, instead of just relying on the previous directory change
in the compilation buffer, all other directories further upwards
will be used as well."
:type 'boolean
:version "28.1")
;;;###autoload
(defcustom compilation-ask-about-save t
"Non-nil means \\[compile] asks which buffers to save before compiling.
Otherwise, it saves all modified buffers without asking."
:type 'boolean)
(defcustom compilation-save-buffers-predicate nil
"The second argument (PRED) passed to `save-some-buffers' before compiling.
E.g., one can set this to
(lambda ()
(string-prefix-p my-compilation-root (file-truename (buffer-file-name))))
to limit saving to files located under `my-compilation-root'.
Note, that, in general, `compilation-directory' cannot be used instead
of `my-compilation-root' here."
:type '(choice
(const :tag "Default (save all file-visiting buffers)" nil)
(const :tag "Save all buffers" t)
function)
:version "24.1")
;;;###autoload
(defcustom compilation-search-path '(nil)
"List of directories to search for source files named in error messages.
Elements should be directory names, not file names of directories.
The value nil as an element means to try the default directory."
:type '(repeat (choice (const :tag "Default" nil)
(string :tag "Directory"))))
;;;###autoload
(defcustom compile-command (purecopy "make -k ")
"Last shell command used to do a compilation; default for next compilation.
Sometimes it is useful for files to supply local values for this variable.
You might also use mode hooks to specify it in certain modes, like this:
(add-hook \\='c-mode-hook
(lambda ()
(unless (or (file-exists-p \"makefile\")
(file-exists-p \"Makefile\"))
(setq-local compile-command
(concat \"make -k \"
(if buffer-file-name
(shell-quote-argument
(file-name-sans-extension buffer-file-name))))))))
It's often useful to leave a space at the end of the value."
:type 'string)
;;;###autoload(put 'compile-command 'safe-local-variable (lambda (a) (and (stringp a) (if (boundp 'compilation-read-command) compilation-read-command t))))
;;;###autoload
(defcustom compilation-disable-input nil
"If non-nil, send end-of-file as compilation process input.
This only affects platforms that support asynchronous processes (see
`start-process'); synchronous compilation processes never accept input."
:type 'boolean
:version "22.1")
;; A weak per-compilation-buffer hash indexed by (FILENAME . DIRECTORY). Each
;; value is a FILE-STRUCTURE as described above, with the car eq to the hash
;; key. This holds the tree seen from root, for storing new nodes.
(defvar compilation-locs ())
(defvar compilation-debug nil
"Set this to t before creating a *compilation* buffer.
Then every error line will have a debug text property with the matcher that
fit this line and the match data. Use `describe-text-properties'.")
(defvar compilation-exit-message-function
(lambda (_process-status exit-status msg) (cons msg exit-status))
"If non-nil, called when a compilation process dies to return a status message.
This should be a function of three arguments: process status, exit status,
and exit message; it returns a cons (MESSAGE . MODELINE) of the strings to
write into the compilation buffer, and to put in its mode line.")
(defcustom compilation-environment nil
"List of environment variables for compilation to inherit.
Each element should be a string of the form ENVVARNAME=VALUE.
This list is temporarily prepended to `process-environment' prior to
starting the compilation process."
:type '(repeat (string :tag "ENVVARNAME=VALUE"))
:options '(("LANG=C"))
:version "24.1")
;; History of compile commands.
(defvar compile-history nil)
(defface compilation-error
'((t :inherit error))
"Face used to highlight compiler errors."
:version "22.1")
(defface compilation-warning
'((t :inherit warning))
"Face used to highlight compiler warnings."
:version "22.1")
(defface compilation-info
'((t :inherit success))
"Face used to highlight compiler information."
:version "22.1")
;; The next three faces must be able to stand out against the
;; `mode-line' and `mode-line-inactive' faces.
(defface compilation-mode-line-fail
'((default :inherit compilation-error)