|
| 1 | +;;; flycheck-matlab-mlint.el --- Flycheck: MATLAB support -*- lexical-binding: t -*- |
| 2 | + |
| 3 | +;;; Commentary: |
| 4 | + |
| 5 | +;; Provides support for MATLAB code checking with mlint and flycheck |
| 6 | +;; that integrates with matlab-mode |
| 7 | +;; |
| 8 | +;; Usage: |
| 9 | +;; |
| 10 | +;; (eval-after-load 'flycheck |
| 11 | +;; '(add-hook 'flycheck-mode-hook #'flycheck-matlab-mlint-setup)) |
| 12 | + |
| 13 | +;;; Code: |
| 14 | + |
| 15 | +(defvar flycheck-checkers) ;; incase flycheck is not on the path |
| 16 | + |
| 17 | +(eval-and-compile |
| 18 | + (when (not (require 'flycheck nil 'noerror)) |
| 19 | + (defmacro flycheck-define-checker (symbol _docstring &rest _properties) |
| 20 | + "To use flycheck SYMBOL, they need to install flycheck." |
| 21 | + (message "To use %S flycheck, you need to install flycheck." symbol)))) |
| 22 | + |
| 23 | +(flycheck-define-checker matlab-mlint |
| 24 | + "A MATLAB checker using MATLAB mlint code analyzer." |
| 25 | + ;; xxx command |
| 26 | + :command ("mlint" "-id" "-all" source-original) |
| 27 | + ;; Example mlint messages. |
| 28 | + ;; L 588 (C 46-49): LOAD: To avoid conflicts with functions on the path, specify variables to load from file. |
| 29 | + ((warning line-start "L " line " (C " column "-" column "): " (id (* alnum)) ":" (message)) |
| 30 | + (warning line-start "L " line " (C " column "): " (id (* alnum)) ":" (message))) |
| 31 | + :modes (matlab-mode) |
| 32 | + :predicate (lambda () (flycheck-buffer-saved-p))) |
| 33 | + |
| 34 | +;;;###autoload |
| 35 | +(defun flycheck-matlab-mlint-setup () |
| 36 | + "Set up Flycheck MATLAB mlint. |
| 37 | +
|
| 38 | +Adds `matlab-mlint' to `flycheck-checkers'." |
| 39 | + (interactive) |
| 40 | + (add-to-list 'flycheck-checkers 'matlab-mlint)) |
| 41 | + |
| 42 | + |
| 43 | +(provide 'flycheck-matlab-mlint) |
| 44 | +;;; flycheck-matlab-mlint.el ends here |
0 commit comments