forked from flycheck/flycheck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flycheck.el
8506 lines (7175 loc) · 326 KB
/
flycheck.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
;;; flycheck.el --- On-the-fly syntax checking -*- lexical-binding: t; -*-
;; Copyright (c) 2012-2016 Sebastian Wiesner and Flycheck contributors
;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
;;
;; Author: Sebastian Wiesner <[email protected]>
;; Maintainer: Sebastian Wiesner <[email protected]>
;; Clément Pit--Claudel <[email protected]>
;; URL: https://www.flycheck.org
;; Keywords: convenience, languages, tools
;; Version: 0.26-cvs
;; Package-Requires: ((dash "2.12.1") (pkg-info "0.4") (let-alist "1.0.4") (seq "1.11") (emacs "24.3"))
;; This file is not part of GNU Emacs.
;; This program 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.
;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; On-the-fly syntax checking for GNU Emacs 24.
;;
;; This package provides on-the-fly syntax checking for GNU Emacs 24. It is a
;; replacement for the older Flymake extension which is part of GNU Emacs, with
;; many improvements and additional features.
;;
;; Flycheck provides fully-automatic, fail-safe, on-the-fly background syntax
;; checking for over 30 programming and markup languages with more than 70
;; different tools. It highlights errors and warnings inline in the buffer, and
;; provides an optional IDE-like error list.
;;
;; It comes with a rich interface for custom syntax checkers and other
;; extensions, and has already many 3rd party extensions adding new features.
;;
;; # Setup
;;
;; Flycheck works best on Unix systems. It does not officially support Windows,
;; but tries to maintain Windows compatibility and should generally work fine on
;; Windows, too.
;;
;; To enable Flycheck add the following to your init file:
;;
;; (add-hook 'after-init-hook #'global-flycheck-mode)
;;
;; Flycheck will then automatically check buffers in supported languages, as
;; long as all necessary tools are present.
;;
;; # Documentation
;;
;; Flycheck comes with a rich manual, which you can read in Emacs with `M-x
;; flycheck-info' after installing this package. It is also available online at
;; URL `http://www.flycheck.org/manual/latest/index.html'.
;;
;; The manual has a Quickstart section which gives you a short and comprehensive
;; introduction into Flycheck's features and usage, and a complete list of all
;; supported languages and tools.
;;; Code:
(eval-when-compile
(require 'let-alist) ; `let-alist'
(require 'compile) ; Compile Mode integration
(require 'jka-compr) ; For JKA workarounds in `flycheck-temp-file-system'
(require 'pcase) ; `pcase-dolist' (`pcase' itself is autoloaded)
)
(require 'dash)
(require 'seq) ; Sequence functions
(require 'subr-x nil 'no-error) ; Additional utilities, Emacs 24.4 and upwards
(require 'cl-lib) ; `cl-defstruct' and CL utilities
(require 'tabulated-list) ; To list errors
(require 'easymenu) ; Flycheck Mode menu definition
(require 'rx) ; Regexp fanciness in `flycheck-define-checker'
(require 'help-mode) ; `define-button-type'
(require 'find-func) ; `find-function-regexp-alist'
;; Declare a bunch of dynamic variables that we need from other modes
(defvar sh-shell) ; For shell script checker predicates
(defvar ess-language) ; For r-lintr predicate
(defvar package-user-dir) ; For emacs-lisp option filters
;; Tell the byte compiler about autoloaded functions from packages
(declare-function pkg-info-version-info "pkg-info" (package))
;;; Compatibility
(eval-and-compile
(unless (fboundp 'string-suffix-p)
;; TODO: Remove when dropping support for Emacs 24.3 and earlier
(defun string-suffix-p (suffix string &optional ignore-case)
"Return non-nil if SUFFIX is a suffix of STRING.
If IGNORE-CASE is non-nil, the comparison is done without paying
attention to case differences."
(let ((start-pos (- (length string) (length suffix))))
(and (>= start-pos 0)
(eq t (compare-strings suffix nil nil
string start-pos nil ignore-case))))))
;; TODO: Remove when dropping support for Emacs 24.3 and earlier
(unless (featurep 'subr-x)
;; `subr-x' function for Emacs 24.3 and below
(defsubst string-join (strings &optional separator)
"Join all STRINGS using SEPARATOR."
(mapconcat 'identity strings separator))
(defsubst string-trim-left (string)
"Remove leading whitespace from STRING."
(if (string-match "\\`[ \t\n\r]+" string)
(replace-match "" t t string)
string))
(defsubst string-trim-right (string)
"Remove trailing whitespace from STRING."
(if (string-match "[ \t\n\r]+\\'" string)
(replace-match "" t t string)
string))
(defsubst string-trim (string)
"Remove leading and trailing whitespace from STRING."
(string-trim-left (string-trim-right string)))
(defsubst string-empty-p (string)
"Check whether STRING is empty."
(string= string ""))))
;;; Customization
(defgroup flycheck nil
"Modern on-the-fly syntax checking for GNU Emacs."
:prefix "flycheck-"
:group 'tools
:link '(url-link :tag "Website" "http://www.flycheck.org")
:link '(url-link :tag "Github" "https://github.com/flycheck/flycheck")
:link '(custom-manual "(flycheck)Top")
:link '(info-link "(flycheck)Usage"))
(defgroup flycheck-config-files nil
"Configuration files for on-the-fly syntax checkers."
:prefix "flycheck-"
:group 'flycheck
:link '(custom-manual "(flycheck)Syntax checker configuration files"))
(defgroup flycheck-options nil
"Options for on-the-fly syntax checkers."
:prefix "flycheck-"
:group 'flycheck
:link '(custom-manual "(flycheck)Syntax checker options"))
(defgroup flycheck-executables nil
"Executables of syntax checkers."
:prefix "flycheck-"
:group 'flycheck
:link '(custom-manual "(flycheck)Syntax checker executables"))
(defgroup flycheck-faces nil
"Faces used by on-the-fly syntax checking."
:prefix "flycheck-"
:group 'flycheck
:link '(info-link "(flycheck)Error reporting"))
(defcustom flycheck-checkers
'(ada-gnat
asciidoc
c/c++-clang
c/c++-gcc
c/c++-cppcheck
cfengine
chef-foodcritic
coffee
coffee-coffeelint
coq
css-csslint
d-dmd
emacs-lisp
emacs-lisp-checkdoc
erlang
eruby-erubis
fortran-gfortran
go-gofmt
go-golint
go-vet
go-build
go-test
go-errcheck
groovy
haml
handlebars
haskell-stack-ghc
haskell-ghc
haskell-hlint
html-tidy
jade
javascript-eslint
javascript-jshint
javascript-gjslint
javascript-jscs
javascript-standard
json-jsonlint
json-python-json
less
luacheck
lua
perl
perl-perlcritic
php
php-phpmd
php-phpcs
processing
puppet-parser
puppet-lint
python-flake8
python-pylint
python-pycompile
r-lintr
racket
rpm-rpmlint
rst-sphinx
rst
ruby-rubocop
ruby-rubylint
ruby
ruby-jruby
rust-cargo
rust
sass
scala
scala-scalastyle
scss-lint
scss
sh-bash
sh-posix-dash
sh-posix-bash
sh-zsh
sh-shellcheck
slim
sql-sqlint
tex-chktex
tex-lacheck
texinfo
verilog-verilator
xml-xmlstarlet
xml-xmllint
yaml-jsyaml
yaml-ruby)
"Syntax checkers available for automatic selection.
A list of Flycheck syntax checkers to choose from when syntax
checking a buffer. Flycheck will automatically select a suitable
syntax checker from this list, unless `flycheck-checker' is set,
either directly or with `flycheck-select-checker'.
You should not need to change this variable normally. In order
to disable syntax checkers, please use
`flycheck-disabled-checkers'. This variable is intended for 3rd
party extensions to tell Flycheck about new syntax checkers.
Syntax checkers in this list must be defined with
`flycheck-define-checker'."
:group 'flycheck
:type '(repeat (symbol :tag "Checker"))
:risky t)
(defcustom flycheck-disabled-checkers nil
"Syntax checkers excluded from automatic selection.
A list of Flycheck syntax checkers to exclude from automatic
selection. Flycheck will never automatically select a syntax
checker in this list, regardless of the value of
`flycheck-checkers'.
However, syntax checkers in this list are still available for
manual selection with `flycheck-select-checker'.
Use this variable to disable syntax checkers, instead of removing
the syntax checkers from `flycheck-checkers'. You may also use
this option as a file or directory local variable to disable
specific checkers in individual files and directories
respectively."
:group 'flycheck
:type '(repeat (symbol :tag "Checker"))
:package-version '(flycheck . "0.16")
:safe #'flycheck-symbol-list-p)
(make-variable-buffer-local 'flycheck-disabled-checkers)
(defvar-local flycheck-checker nil
"Syntax checker to use for the current buffer.
If unset or nil, automatically select a suitable syntax checker
from `flycheck-checkers' on every syntax check.
If set to a syntax checker only use this syntax checker and never
select one from `flycheck-checkers' automatically. The syntax
checker is used regardless of whether it is contained in
`flycheck-checkers' or `flycheck-disabled-checkers'. If the
syntax checker is unusable in the current buffer an error is
signaled.
A syntax checker assigned to this variable must be defined with
`flycheck-define-checker'.
Use the command `flycheck-select-checker' to select a syntax
checker for the current buffer, or set this variable as file
local variable to always use a specific syntax checker for a
file. See Info Node `(emacs)Specifying File Variables' for more
information about file variables.")
(put 'flycheck-checker 'safe-local-variable 'flycheck-registered-checker-p)
(defcustom flycheck-locate-config-file-functions nil
"Functions to locate syntax checker configuration files.
Each function in this hook must accept two arguments: The value
of the configuration file variable, and the syntax checker
symbol. It must return either a string with an absolute path to
the configuration file, or nil, if it cannot locate the
configuration file.
The functions in this hook are called in order of appearance, until a
function returns non-nil. The configuration file returned by that
function is then given to the syntax checker if it exists.
This variable is an abnormal hook. See Info
node `(elisp)Hooks'."
:group 'flycheck
:type 'hook
:risky t)
(defcustom flycheck-checker-error-threshold 400
"Maximum errors allowed per syntax checker.
The value of this variable is either an integer denoting the
maximum number of errors per syntax checker and buffer, or nil to
not limit the errors reported from a syntax checker.
If this variable is a number and a syntax checker reports more
errors than the value of this variable, its errors are not
discarded, and not highlighted in the buffer or available in the
error list. The affected syntax checker is also disabled for
future syntax checks of the buffer."
:group 'flycheck
:type '(choice (const :tag "Do not limit reported errors" nil)
(integer :tag "Maximum number of errors"))
:risky t
:package-version '(flycheck . "0.22"))
(defcustom flycheck-process-error-functions nil
"Functions to process errors.
Each function in this hook must accept a single argument: A
Flycheck error to process.
All functions in this hook are called in order of appearance,
until a function returns non-nil. Thus, a function in this hook
may return nil, to allow for further processing of the error, or
any non-nil value, to indicate that the error was fully processed
and inhibit any further processing.
The functions are called for each newly parsed error immediately
after the corresponding syntax checker finished. At this stage,
the overlays from the previous syntax checks are still present,
and there may be further syntax checkers in the chain.
This variable is an abnormal hook. See Info
node `(elisp)Hooks'."
:group 'flycheck
:type 'hook
:package-version '(flycheck . "0.13")
:risky t)
(defcustom flycheck-display-errors-delay 0.9
"Delay in seconds before displaying errors at point.
Use floating point numbers to express fractions of seconds."
:group 'flycheck
:type 'number
:package-version '(flycheck . "0.15")
:safe #'numberp)
(defcustom flycheck-display-errors-function #'flycheck-display-error-messages
"Function to display error messages.
If set to a function, call the function with the list of errors
to display as single argument. Each error is an instance of the
`flycheck-error' struct.
If set to nil, do not display errors at all."
:group 'flycheck
:type '(choice (const :tag "Display error messages"
flycheck-display-error-messages)
(const :tag "Display error messages only if no error list"
flycheck-display-error-messages-unless-error-list)
(function :tag "Error display function"))
:package-version '(flycheck . "0.13")
:risky t)
(defcustom flycheck-help-echo-function #'flycheck-help-echo-all-error-messages
"Function to compute the contents of the error tooltips.
If set to a function, call the function with the list of errors
to display as single argument. Each error is an instance of the
`flycheck-error' struct. The function is used to set the
help-echo property of flycheck error overlays. It should return
a string, which is displayed when the user hovers over an error
or presses \\[display-local-help].
If set to nil, do not show error tooltips."
:group 'flycheck
:type '(choice (const :tag "Concatenate error messages to form a tooltip"
flycheck-help-echo-all-error-messages)
(function :tag "Help echo function"))
:package-version '(flycheck . "0.25")
:risky t)
(defcustom flycheck-command-wrapper-function #'identity
"Function to modify checker commands before execution.
The value of this option is a function which is given a list
containing the full command of a syntax checker after
substitution through `flycheck-substitute-argument' but before
execution. The function may return a new command for Flycheck to
execute.
The default value is `identity' which does not change the
command. You may provide your own function to run Flycheck
commands through `bundle exec', `nix-shell' or similar wrappers."
:group 'flycheck
:type '(choice (const :tag "Do not modify commands" identity)
(function :tag "Modify command with a custom function"))
:package-version '(flycheck . "0.25")
:risky t)
(defcustom flycheck-executable-find #'executable-find
"Function to search for executables.
The value of this option is a function which is given the name or
path of an executable and shall return the full path to the
executable, or nil if the executable does not exit.
The default is the standard `executable-find' function which
searches `exec-path'. You can customize this option to search
for checkers in other environments such as bundle or NixOS
sandboxes."
:group 'flycheck
:type '(choice (const :tag "Search executables in `exec-path'" executable-find)
(function :tag "Search executables with a custom function"))
:package-version '(flycheck . "0.25")
:risky t)
(defcustom flycheck-indication-mode 'left-fringe
"The indication mode for Flycheck errors and warnings.
This variable controls how Flycheck indicates errors in buffers.
May either be `left-fringe', `right-fringe', or nil.
If set to `left-fringe' or `right-fringe', indicate errors and
warnings via icons in the left and right fringe respectively.
If set to nil, do not indicate errors and warnings, but just
highlight them according to `flycheck-highlighting-mode'."
:group 'flycheck
:type '(choice (const :tag "Indicate in the left fringe" left-fringe)
(const :tag "Indicate in the right fringe" right-fringe)
(const :tag "Do not indicate" nil))
:safe #'symbolp)
(defcustom flycheck-highlighting-mode 'symbols
"The highlighting mode for Flycheck errors and warnings.
The highlighting mode controls how Flycheck highlights errors in
buffers. The following modes are known:
`columns'
Highlight the error column. If the error does not have a column,
highlight the whole line.
`symbols'
Highlight the symbol at the error column, if there is any,
otherwise behave like `columns'. This is the default.
`sexps'
Highlight the expression at the error column, if there is
any, otherwise behave like `columns'. Note that this mode
can be *very* slow in some major modes.
`lines'
Highlight the whole line.
nil
Do not highlight errors at all. However, errors will still
be reported in the mode line and in error message popups,
and indicated according to `flycheck-indication-mode'."
:group 'flycheck
:type '(choice (const :tag "Highlight columns only" columns)
(const :tag "Highlight symbols" symbols)
(const :tag "Highlight expressions" sexps)
(const :tag "Highlight whole lines" lines)
(const :tag "Do not highlight errors" nil))
:package-version '(flycheck . "0.14")
:safe #'symbolp)
(defcustom flycheck-check-syntax-automatically '(save
idle-change
new-line
mode-enabled)
"When Flycheck should check syntax automatically.
This variable is a list of events that may trigger syntax checks.
The following events are known:
`save'
Check syntax immediately after the buffer was saved.
`idle-change'
Check syntax a short time (see `flycheck-idle-change-delay')
after the last change to the buffer.
`new-line'
Check syntax immediately after a new line was inserted into
the buffer.
`mode-enabled'
Check syntax immediately when `flycheck-mode' is enabled.
Flycheck performs a syntax checks only on events, which are
contained in this list. For instance, if the value of this
variable is `(mode-enabled save)', Flycheck will only check if
the mode is enabled or the buffer was saved, but never after
changes to the buffer contents.
If nil, never check syntax automatically. In this case, use
`flycheck-buffer' to start a syntax check manually."
:group 'flycheck
:type '(set (const :tag "After the buffer was saved" save)
(const :tag "After the buffer was changed and idle" idle-change)
(const :tag "After a new line was inserted" new-line)
(const :tag "After `flycheck-mode' was enabled" mode-enabled))
:package-version '(flycheck . "0.12")
:safe #'symbolp)
(defcustom flycheck-idle-change-delay 0.5
"How many seconds to wait before checking syntax automatically.
After the buffer was changed, Flycheck will wait as many seconds
as the value of this variable before starting a syntax check. If
the buffer is modified during this time, Flycheck will wait
again.
This variable has no effect, if `idle-change' is not contained in
`flycheck-check-syntax-automatically'."
:group 'flycheck
:type 'number
:package-version '(flycheck . "0.13")
:safe #'numberp)
(defcustom flycheck-standard-error-navigation t
"Whether to support error navigation with `next-error'.
If non-nil, enable navigation of Flycheck errors with
`next-error', `previous-error' and `first-error'. Otherwise,
these functions just navigate errors from compilation modes.
Flycheck error navigation with `flycheck-next-error',
`flycheck-previous-error' and `flycheck-first-error' is always
enabled, regardless of the value of this variable.
Note that this setting only takes effect when `flycheck-mode' is
enabled. Changing it will not affect buffers which already have
`flycheck-mode' enabled."
:group 'flycheck
:type 'boolean
:package-version '(flycheck . "0.15")
:safe #'booleanp)
(define-widget 'flycheck-minimum-level 'lazy
"A radio-type choice of minimum error levels.
See `flycheck-navigation-minimum-level' and
`flycheck-error-list-minimum-level'."
:type '(radio (const :tag "All locations" nil)
(const :tag "Informational messages" info)
(const :tag "Warnings" warning)
(const :tag "Errors" error)
(symbol :tag "Custom error level")))
(defcustom flycheck-navigation-minimum-level nil
"The minimum level of errors to navigate.
If set to an error level, only navigate errors whose error level
is at least as severe as this one. If nil, navigate all errors."
:group 'flycheck
:type 'flycheck-minimum-level
:safe #'flycheck-error-level-p
:package-version '(flycheck . "0.21"))
(defcustom flycheck-error-list-minimum-level nil
"The minimum level of errors to display in the error list.
If set to an error level, only display errors whose error level
is at least as severe as this one in the error list. If nil,
display all errors.
This is the default level, used when the error list is opened.
You can temporarily change the level using
\\[flycheck-error-list-set-filter], or reset it to this value
using \\[flycheck-error-list-reset-filter]."
:group 'flycheck
:type 'flycheck-minimum-level
:safe #'flycheck-error-level-p
:package-version '(flycheck . "0.24"))
(defcustom flycheck-completing-read-function #'completing-read
"Function to read from minibuffer with completion.
The function must be compatible to the built-in `completing-read'
function."
:group 'flycheck
:type '(choice (const :tag "Default" completing-read)
(const :tag "IDO" ido-completing-read)
(function :tag "Custom function"))
:risky t
:package-version '(flycheck . "0.26"))
(defcustom flycheck-temp-prefix "flycheck"
"Prefix for temporary files created by Flycheck."
:group 'flycheck
:type 'string
:package-version '(flycheck . "0.19")
:risky t)
(defcustom flycheck-mode-hook nil
"Hooks to run after `flycheck-mode'."
:group 'flycheck
:type 'hook
:risky t)
(defcustom flycheck-after-syntax-check-hook nil
"Functions to run after each syntax check.
This hook is run after a syntax check was finished.
At this point, *all* chained checkers were run, and all errors
were parsed, highlighted and reported. The variable
`flycheck-current-errors' contains all errors from all syntax
checkers run during the syntax check, so you can apply any error
analysis functions.
Note that this hook does *not* run after each individual syntax
checker in the syntax checker chain, but only after the *last
checker*.
This variable is a normal hook. See Info node `(elisp)Hooks'."
:group 'flycheck
:type 'hook
:risky t)
(defcustom flycheck-before-syntax-check-hook nil
"Functions to run before each syntax check.
This hook is run right before a syntax check starts.
Error information from the previous syntax check is *not*
cleared before this hook runs.
Note that this hook does *not* run before each individual syntax
checker in the syntax checker chain, but only before the *first
checker*.
This variable is a normal hook. See Info node `(elisp)Hooks'."
:group 'flycheck
:type 'hook
:risky t)
(defcustom flycheck-syntax-check-failed-hook nil
"Functions to run if a syntax check failed.
This hook is run whenever an error occurs during Flycheck's
internal processing. No information about the error is given to
this hook.
You should use this hook to conduct additional cleanup actions
when Flycheck failed.
This variable is a normal hook. See Info node `(elisp)Hooks'."
:group 'flycheck
:type 'hook
:risky t)
(defcustom flycheck-status-changed-functions nil
"Functions to run if the Flycheck status changed.
This hook is run whenever the status of Flycheck changes. Each
hook function takes the status symbol as sinlge argument, as
given to `flycheck-report-status', which see.
This variable is a abnormal hook. See Info
node `(elisp)Hooks'."
:group 'flycheck
:type 'hook
:risky t
:package-version '(flycheck . "0.20"))
(defcustom flycheck-error-list-after-refresh-hook nil
"Functions to run after the error list was refreshed.
This hook is run whenever the error list is refreshed.
This variable is a normal hook. See Info node `(elisp)Hooks'."
:group 'flycheck
:type 'hook
:risky t
:package-version '(flycheck . "0.21"))
(defface flycheck-error
'((((supports :underline (:style wave)))
:underline (:style wave :color "Red1"))
(t
:underline t :inherit error))
"Flycheck face for errors."
:package-version '(flycheck . "0.13")
:group 'flycheck-faces)
(defface flycheck-warning
'((((supports :underline (:style wave)))
:underline (:style wave :color "DarkOrange"))
(t
:underline t :inherit warning))
"Flycheck face for warnings."
:package-version '(flycheck . "0.13")
:group 'flycheck-faces)
(defface flycheck-info
'((((supports :underline (:style wave)))
:underline (:style wave :color "ForestGreen"))
(t
:underline t :inherit success))
"Flycheck face for informational messages."
:package-version '(flycheck . "0.15")
:group 'flycheck-faces)
(defface flycheck-fringe-error
'((t :inherit error))
"Flycheck face for fringe error indicators."
:package-version '(flycheck . "0.13")
:group 'flycheck-faces)
(defface flycheck-fringe-warning
'((t :inherit warning))
"Flycheck face for fringe warning indicators."
:package-version '(flycheck . "0.13")
:group 'flycheck-faces)
(defface flycheck-fringe-info
;; Semantically `success' is probably not the right face, but it looks nice as
;; a base face
'((t :inherit success))
"Flycheck face for fringe info indicators."
:package-version '(flycheck . "0.15")
:group 'flycheck-faces)
(defface flycheck-error-list-error
'((t :inherit error))
"Flycheck face for error messages in the error list."
:package-version '(flycheck . "0.16")
:group 'flycheck-faces)
(defface flycheck-error-list-warning
'((t :inherit warning))
"Flycheck face for warning messages in the error list."
:package-version '(flycheck . "0.16")
:group 'flycheck-faces)
(defface flycheck-error-list-info
'((t :inherit success))
"Flycheck face for info messages in the error list."
:package-version '(flycheck . "0.16")
:group 'flycheck-faces)
;; The base faces for the following two faces are inspired by Compilation Mode
(defface flycheck-error-list-line-number
'((t :inherit font-lock-constant-face))
"Face for line numbers in the error list."
:group 'flycheck-faces
:package-version '(flycheck . "0.16"))
(defface flycheck-error-list-column-number
'((t :inherit font-lock-constant-face))
"Face for line numbers in the error list."
:group 'flycheck-faces
:package-version '(flycheck . "0.16"))
(defface flycheck-error-list-id
'((t :inherit font-lock-type-face))
"Face for the error ID in the error list."
:group 'flycheck-faces
:package-version '(flycheck . "0.22"))
(defface flycheck-error-list-checker-name
'((t :inherit font-lock-function-name-face))
"Face for the syntax checker name in the error list."
:group 'flycheck-faces
:package-version '(flycheck . "0.21"))
(defface flycheck-error-list-highlight
'((t :inherit highlight))
"Flycheck face to highlight errors in the error list."
:package-version '(flycheck . "0.15")
:group 'flycheck-faces)
(defvar flycheck-command-map
(let ((map (make-sparse-keymap)))
(define-key map "c" #'flycheck-buffer)
(define-key map "C" #'flycheck-clear)
(define-key map (kbd "C-c") #'flycheck-compile)
(define-key map "n" #'flycheck-next-error)
(define-key map "p" #'flycheck-previous-error)
(define-key map "l" #'flycheck-list-errors)
(define-key map (kbd "C-w") #'flycheck-copy-errors-as-kill)
(define-key map "s" #'flycheck-select-checker)
(define-key map "e" #'flycheck-set-checker-executable)
(define-key map "?" #'flycheck-describe-checker)
(define-key map "h" #'flycheck-display-error-at-point)
(define-key map "H" #'display-local-help)
(define-key map "i" #'flycheck-info)
(define-key map "V" #'flycheck-version)
(define-key map "v" #'flycheck-verify-setup)
(define-key map "x" #'flycheck-disable-checker)
map)
"Keymap of Flycheck interactive commands.")
(defcustom flycheck-keymap-prefix (kbd "C-c !")
"Prefix for key bindings of Flycheck.
Changing this variable outside Customize does not have any
effect. To change the keymap prefix from Lisp, you need to
explicitly re-define the prefix key:
(define-key flycheck-mode-map flycheck-keymap-prefix nil)
(setq flycheck-keymap-prefix (kbd \"C-c f\"))
(define-key flycheck-mode-map flycheck-keymap-prefix
flycheck-command-map)
Please note that Flycheck's manual documents the default
keybindings. Changing this variable is at your own risk."
:group 'flycheck
:package-version '(flycheck . "0.19")
:type 'string
:risky t
:set
(lambda (variable key)
(when (and (boundp variable) (boundp 'flycheck-mode-map))
(define-key flycheck-mode-map (symbol-value variable) nil)
(define-key flycheck-mode-map key flycheck-command-map))
(set-default variable key)))
(defcustom flycheck-mode-line '(:eval (flycheck-mode-line-status-text))
"Mode line lighter for Flycheck.
The value of this variable is a mode line template as in
`mode-line-format'. See Info Node `(elisp)Mode Line Format' for
more information. Note that it should contain a _single_ mode
line construct only.
Customize this variable to change how Flycheck reports its status
in the mode line. You may use `flycheck-mode-line-status-text'
to obtain a human-readable status text, including an
error/warning count.
You may also assemble your own status text. The current status
of Flycheck is available in `flycheck-last-status-change'. The
errors in the current buffer are stored in
`flycheck-current-errors', and the function
`flycheck-count-errors' may be used to obtain the number of
errors grouped by error level.
Set this variable to nil to disable the mode line completely."
:group 'flycheck
:type 'sexp
:risky t
:package-version '(flycheck . "0.20"))
(defcustom flycheck-mode-line-prefix "FlyC"
"Base mode line lighter for Flycheck.
This will have an effect only with the default
`flycheck-mode-line'.
If you've customized `flycheck-mode-line' then the customized
function must be updated to use this variable."
:group 'flycheck
:type 'string
:package-version '(flycheck . "0.26"))
(defcustom flycheck-error-list-mode-line
`(,(propertized-buffer-identification "%12b")
" for buffer "
(:eval (flycheck-error-list-propertized-source-name))
(:eval (flycheck-error-list-mode-line-filter-indicator)))
"Mode line construct for Flycheck error list.
The value of this variable is a mode line template as in
`mode-line-format', to be used as
`mode-line-buffer-identification' in `flycheck-error-list-mode'.
See Info Node `(elisp)Mode Line Format' for more information.
Customize this variable to change how the error list appears in
the mode line. The default shows the name of the buffer and the
name of the source buffer, i.e. the buffer whose errors are
currently listed."
:group 'flycheck
:type 'sexp
:risky t
:package-version '(flycheck . "0.20"))
(defcustom flycheck-global-modes t
"Modes for which `flycheck-mode' is turned on by `global-flycheck-mode'.
If t, Flycheck Mode is turned on for all major modes. If a list,
Flycheck Mode is turned on for all `major-mode' symbols in that
list. If the `car' of the list is `not', Flycheck Mode is turned
on for all `major-mode' symbols _not_ in that list. If nil,
Flycheck Mode is never turned on by `global-flycheck-mode'.
Note that Flycheck is never turned on for modes whose
`mode-class' property is `special' (see Info node `(elisp)Major
Mode Conventions'), regardless of the value of this option."
:group 'flycheck
:type '(choice (const :tag "none" nil)
(const :tag "all" t)
(set :menu-tag "mode specific" :tag "modes"
:value (not)
(const :tag "Except" not)
(repeat :inline t (symbol :tag "mode"))))
:risky t
:package-version '(flycheck . "0.23"))
;; Add built-in functions to our hooks, via `add-hook', to make sure that our
;; functions are really present, even if the variable was implicitly defined by
;; another call to `add-hook' that occurred before Flycheck was loaded. See
;; http://lists.gnu.org/archive/html/emacs-devel/2015-02/msg01271.html for why
;; we don't initialize the hook variables right away. We append our own
;; functions, because a user likely expects that their functions come first,
;; even if the added them before Flycheck was loaded.
(dolist (hook (list #'flycheck-locate-config-file-by-path
#'flycheck-locate-config-file-ancestor-directories
#'flycheck-locate-config-file-home))
(add-hook 'flycheck-locate-config-file-functions hook 'append))
(add-hook 'flycheck-process-error-functions #'flycheck-add-overlay 'append)
;;; Global Flycheck menu
(defvar flycheck-mode-menu-map
(easy-menu-create-menu
"Syntax Checking"
'(["Enable on-the-fly syntax checking" flycheck-mode
:style toggle :selected flycheck-mode
;; Don't let users toggle the mode if there is no syntax checker for this
;; buffer
:enable (or flycheck-mode (flycheck-get-checker-for-buffer))]
["Check current buffer" flycheck-buffer flycheck-mode]
["Clear errors in buffer" flycheck-clear t]
"---"
["Go to next error" flycheck-next-error flycheck-mode]
["Go to previous error" flycheck-previous-error flycheck-mode]
["Show all errors" flycheck-list-errors flycheck-mode]
"---"
["Copy messages at point" flycheck-copy-errors-as-kill
(flycheck-overlays-at (point))]
"---"
["Select syntax checker" flycheck-select-checker flycheck-mode]
["Disable syntax checker" flycheck-disable-checker flycheck-mode]
["Set executable of syntax checker" flycheck-set-checker-executable
flycheck-mode]
"---"
["Describe syntax checker" flycheck-describe-checker t]
["Show Flycheck version" flycheck-version t]
["Read the Flycheck manual" flycheck-info t]))
"Menu of `flycheck-mode'.")
(easy-menu-add-item nil '("Tools") flycheck-mode-menu-map "Spell Checking")
;;; Version information, manual and loading of Flycheck
(defun flycheck-version (&optional show-version)
"Get the Flycheck version as string.
If called interactively or if SHOW-VERSION is non-nil, show the
version in the echo area and the messages buffer.