In this example, we will add support for perl as a syntax check
tool. perl supports the -c option which does syntax
checking.
First, we write the init-function:
(defun flymake-perl-init (buffer)
(let* ((temp-file (flymake-init-create-temp-buffer-copy
buffer 'flymake-create-temp-inplace))
(local-file (concat (flymake-build-relative-filename
(file-name-directory
(buffer-file-name
(current-buffer)))
(file-name-directory temp-file))
(file-name-nondirectory temp-file))))
(list "perl" (list "-wc " local-file))))
flymake-perl-init creates a temporary copy of the buffer
contents with the help of
flymake-init-create-temp-buffer-copy, and builds an appropriate
command line.
Next, we add a new entry to the
flymake-allowed-file-name-masks:
(setq flymake-allowed-file-name-masks
(cons '(".+\\.pl$"
flymake-perl-init
flymake-simple-cleanup
flymake-get-real-file-name)
flymake-allowed-file-name-masks))
Note that we use standard cleanup-function and
getfname-function.
Finally, we add an entry to flymake-err-line-patterns:
(setq flymake-err-line-patterns
(cons '("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]"
2 3 nil 1)
flymake-err-line-patterns))