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-proc-perl-init () (let* ((temp-file (flymake-proc-init-create-temp-buffer-copy 'flymake-proc-create-temp-inplace)) (local-file (file-relative-name temp-file (file-name-directory buffer-file-name)))) (list "perl" (list "-wc " local-file))))
flymake-proc-perl-init
creates a temporary copy of the buffer
contents with the help of
flymake-proc-init-create-temp-buffer-copy
, and builds an appropriate
command line.
Next, we add a new entry to the
flymake-proc-allowed-file-name-masks
:
(setq flymake-proc-allowed-file-name-masks (cons '(".+\\.pl$" flymake-proc-perl-init flymake-proc-simple-cleanup flymake-proc-get-real-file-name) flymake-proc-allowed-file-name-masks))
Note that we use standard cleanup-function
and
getfname-function
.
Finally, we add an entry to flymake-proc-err-line-patterns
:
(setq flymake-proc-err-line-patterns (cons '("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1) flymake-proc-err-line-patterns))