Skip to content

Commit a15e91b

Browse files
committed
flycheck-matlab-mlint: initial flycheck setup
1 parent 1d5e30c commit a15e91b

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

flycheck-matlab-mlint.el

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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

Comments
 (0)