Emacs package that provides an easy way to define flymake checkers.
For example, a pycodestyle checker can be defined like this:
(pycodestyle
:class pipe
:modes (python-mode)
:command "pycodestyle -"
:error-patterns
((:warning
(line-start file ":" line ":" column ": " (message (zero-or-more nonl)) line-end))))Call flymake-x-setup once, and modify flymake-x-checkers. This variable is
a list of checker definitions.
See sample-checkers.el for an example.
Each checker should look like this:
(NAME ; a symbol
:class flymake-x-TYPE-checker
:modes MODE-LIST
:command "COMMAND"
:stderr t
:lines-start-from-0 t
:columns-start-from-1 t
:error-patterns
((:KIND
RX-STYLE-CONSTRUCT)
(:KIND
RX-STYLE-CONSTRUCT)
...))The keyword arguments to each checker are:
-
:class CLASSRequired. This says how the checker process will accept input. This is one of:
flymake-x-pipe-checker(or justpipe)
The checker will accept the buffer string via stdin.
flymake-x-temp-file-checker(or justtemp-file)
A temporary file will be created with the buffer contents, and it's path will be passed as an argument to the checker process.
-
:command COMMANDRequired. This is the shell command (string) to run. It can also be a function that accepts no arguments and returns the command string.
-
:error-patterns PATTERNSRequired. This defines the patterns to search for in the checker process output.
Each pattern is a list
(KIND RX-PAT [MSG]). KIND can be:note,:warningor:error.RX-PAT is an
rx-style pattern (a sexp) and these additionalrxconstructs are available in it:line
matches
"[0-9]+"and is used to extract line numbercolumn
matches
"[0-9]+"and is used to extract column number(message PAT)
matches PAT and is used to extract the error message
file
matches
".*"and is used to extract the file nameMSG can be provided to set the diagnostic message for the pattern. Otherwise, it should be matched by the pattern.
The patterns are searched in order, line-by-line from the beginning of the checker's output.
-
:modes MODESOptional. If this is present, only run the checker in given modes. By default, a checker will be run in all modes where
flymake-modeis enabled. -
:stderr tOptional. If this is non-nil, standard error of the checker process will be used to search for the error patterns instead of stdout.
-
:lines-start-from-0 tOptional. If non-nil, assume lines start from 0.
-
:columns-start-from-1 tOptional. If non-nil, assume columns start from 1.
Copyright (C) 2019-2024 Michał Krzywkowski
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 <https://www.gnu.org/licenses/>.