branch: externals/matlab-mode commit 1572aa85f729260dea47f9c3a1f010f0887c1d46 Author: John Ciolfi <cio...@mathworks.com> Commit: John Ciolfi <cio...@mathworks.com>
matlab-ts-mode: updated mlint to use matlab--get-mlint-exe --- matlab--access.el | 2 +- matlab-ts-mode.el | 55 +++++++++++++++++++++++++++++++------------------------ 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/matlab--access.el b/matlab--access.el index 624f6b5981..920993a934 100644 --- a/matlab--access.el +++ b/matlab--access.el @@ -269,7 +269,7 @@ the \"mlint\" entry in `mlint-programs', in which case this is the mlint next to the matlab found by `matlab--get-abs-matlab-exe'. If we resolved another entry in `mlint-programs', we'll use that and by convention that entry should be an absolute path, but that's not -guaranteed." +guaranteed. Nil is returned if mlint is not found." (let (mlint-exe) (cl-loop for mlint in mlint-programs do (if (string= mlint "mlint") diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el index e2bbc07e34..cfc436f422 100644 --- a/matlab-ts-mode.el +++ b/matlab-ts-mode.el @@ -36,6 +36,8 @@ ;;; Code: (require 'treesit) + +(require 'matlab--access) (require 'matlab-ts-mode--builtins) ;;; Customizations @@ -2030,30 +2032,35 @@ https://github.com/acristoffers/tree-sitter-matlab/issues/34" (defvar flycheck-checkers) ;; incase flycheck is not on the path -(eval-and-compile - (when (not (require 'flycheck nil 'noerror)) - (defmacro flycheck-define-checker (symbol _docstring &rest _properties) - "To use flycheck SYMBOL, they need to install flycheck." - (message "To use %S flycheck, you need to install flycheck." symbol)))) - -(flycheck-define-checker matlab-mlint - "A MATLAB checker using MATLAB mlint code analyzer." - ;; TODO use matlab--get-mlint-exe instead of assuming mlint is on path - :command ("mlint" "-id" "-all" source-original) - ;; Example mlint messages. - ;; L 588 (C 46-49): LOAD: To avoid conflicts with functions .... - :error-patterns - ((warning line-start "L " line " (C " column "-" column "): " (id (* alnum)) ":" (message)) - (warning line-start "L " line " (C " column "): " (id (* alnum)) ":" (message))) - :modes (matlab-ts-mode) - :predicate (lambda () (flycheck-buffer-saved-p))) - -;; Register flycheck -(when matlab-ts-mode-enable-mlint-flycheck - (if (require 'flycheck nil 'noerror) - (add-to-list 'flycheck-checkers 'matlab-mlint) - (message "matlab-ts-mode: no flycheck, unable to activate mlint - \ -to fix install https://www.flycheck.org"))) +(declare-function flycheck-define-command-checker "flycheck") +(declare-function flycheck-buffer-saved-p "flycheck") + +;; TODO - do we need to disable when lsp is active? + +(if (require 'flycheck nil 'noerror) + (let* ((mlint (matlab--get-mlint-exe))) + (if (not mlint) + ;; TODO - dislay when activating matlab-ts-mode? + (message "mlint code analyzer not found, not activating flycheck for MATLAB. +To fix, place matlab on your system path or configure `matlab-shell-command'") + (flycheck-define-command-checker + 'matlab + "MATLAB mlint code analyzer" + :command `(,mlint "-id" "-all" source-original) + ;; Example mlint messages. + ;; L 588 (C 46-49): LOAD: To avoid conflicts with functions .... + :error-patterns + '((warning line-start "L " line " (C " column "-" column "): " + (id (* alnum)) ":" (message)) + (warning line-start "L " line " (C " column "): " + (id (* alnum)) ":" (message))) + :modes '(matlab-ts-mode) + :predicate #'(lambda () (flycheck-buffer-saved-p))) + ;; Register matlab-mlint with flycheck + (add-to-list 'flycheck-checkers 'matlab-mlint) + )) + (message "matlab-ts-mode: no flycheck, unable to activate mlint - \ +to fix install https://www.flycheck.org")) ;;;###autoload (define-derived-mode matlab-ts-mode prog-mode "MATLAB:ts"