Check buffers¶
Flycheck provides two Emacs minor modes for automatic syntax checking:
Flycheck Mode
to enable syntax checking in the current buffer, and
Global Flycheck Mode
to enable syntax checking in all buffers whenever
possible.
-
Minor Mode
Flycheck Mode
¶ Enable automatic syntax checking in the current buffer.
-
Minor Mode
Global Flycheck Mode
¶ Enable
Flycheck Mode
in all buffers where syntax checking is possible.Note
This mode does not enable
Flycheck Mode
in remote files (via TRAMP) and encrypted files. Checking remote files may be very slow depending on the network connections, and checking encrypted files would leak confidential data to temporary files and subprocesses.You can manually enable
Flycheck Mode
in these buffers nonetheless, but we do not recommend this for said reasons.Add the following to your init file to enable syntax checking permanently:
(add-hook 'after-init-hook #'global-flycheck-mode)
You can exclude specific major modes from syntax checking with
flycheck-global-modes
:-
defcustom
flycheck-global-modes
¶ Major modes for which
Global Flycheck Mode
turns onFlycheck Mode
:t
(the default)- Turn
Flycheck Mode
on for all major modes. (foo-mode …)
- Turn
Flycheck Mode
on for all major modes in this list, i.e. whenever the value ofmajor-mode
is contained in this list. (not foo-mode …)
- Turn
Flycheck Mode
on for all major nodes not in this list, i.e. whenever the value ofmajor-mode
is not contained in this list.
Note
Global Flycheck Mode
never turns onFlycheck Mode
in major modes whosemode-class
property isspecial
, regardless of the value of this option. Syntax checking simply makes no sense in special buffers which are typically intended for non-interactive display rather than editing.See also
- Major Mode Conventions(elisp)
- Information about major modes, and modes marked as special.
-
defcustom
Check automatically¶
By default Flycheck Mode
automatically checks a buffer whenever
- it is enabled,
- the buffer is saved,
- a new line is inserted,
- or a short time after the last change was made in a buffer.
You can customise this behaviour with flycheck-check-syntax-automatically
:
-
defcustom
flycheck-check-syntax-automatically
¶ A list of events which trigger a syntax check in the current buffer:
save
- Check the buffer immediately after it was saved.
new-line
- Check the buffer immediately after a new line was inserted.
idle-change
Check the buffer a short time after the last change. The delay is customisable with
flycheck-idle-change-delay
:-
defcustom
flycheck-idle-change-delay
¶ Seconds to wait after the last change to the buffer before starting a syntax check.
-
defcustom
mode-enabled
- Check the buffer immediately after
Flycheck Mode
was enabled.
For instance with the following setting
Flycheck Mode
will only check the buffer when it was saved:(setq flycheck-check-syntax-automatically '(mode-enabled save))
Debug syntax checking¶
To make sure that syntax checking works correctly verify your setup:
-
C-c ! v
¶ -
M-x flycheck-verify-setup
¶ Show a buffer with information about your
Flycheck Mode
setup for the current buffer.Lists all syntax checkers available for the current buffer, and potential issues with their setup.