branch: externals/matlab-mode
commit f20fe6a5bc35221f612a93099c9375e002b1f712
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>
matlab-ts-mode: fix indent involving catch clause with a comment
---
NEWS.org | 4 ++++
matlab-mode.el | 2 +-
matlab-ts-mode.el | 8 +++++++-
matlab.el | 2 +-
.../test-matlab-ts-mode-indent-files/indent_catch_with_comment.m | 7 +++++++
.../indent_catch_with_comment_expected.m | 7 +++++++
.../indent_catch_with_comment_expected_msgs.m | 7 +++++++
.../indent_comment_after_prop_expected_msgs.m | 2 +-
8 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 0f9fa0e677..3ec76ddcee 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -3,6 +3,10 @@
# Copyright (C) 2025 Free Software Foundation, Inc.
+* Release 7.2.1 Oct 30, 2025
+
+1. In matlab-ts-mode, fix indent involving catch clause with a comment.
+
* Release 7.2.0 Oct 29, 2025
1. Updated matlab-ts-mode to use latest matlab tree-sitter v1.2.3 branch
[[https://github.com/acristoffers/tree-sitter-matlab/tree/abi/14][abi/14]] at
[[https://github.com/acristoffers/tree-sitter-matlab/tree/9a4e65df4bb08e2b019ca2ef16b2d8f3d95ce978][9a4e65d]].
This
diff --git a/matlab-mode.el b/matlab-mode.el
index d605217363..8ab47c4a0f 100644
--- a/matlab-mode.el
+++ b/matlab-mode.el
@@ -1,6 +1,6 @@
;;; matlab-mode.el --- Major mode for MATLAB(R) dot-m files -*-
lexical-binding: t -*-
-;; Version: 7.2.0
+;; Version: 7.2.1
;; URL: https://github.com/mathworks/Emacs-MATLAB-Mode
;; SPDX-License-Identifier: GPL-3.0-or-later
diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el
index a201dcd960..4733107f67 100644
--- a/matlab-ts-mode.el
+++ b/matlab-ts-mode.el
@@ -1,6 +1,6 @@
;;; matlab-ts-mode.el --- MATLAB(R) Tree-Sitter Mode -*- lexical-binding: t -*-
-;; Version: 7.2.0
+;; Version: 7.2.1
;; URL: https://github.com/mathworks/Emacs-MATLAB-Mode
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -2488,6 +2488,12 @@ Example:
((parent-is ,(rx bos (or "try_statement" "catch_clause") eos))
parent ,matlab-ts-mode--indent-level)
+ ;; I-Rule: catch err %#ok (the comment causes a block to appear)
+ ;; TAB> disp('catch');
+ ;; See: tests/test-matlab-ts-mode-indent-files/indent_catch_with_comment.m
+ ((n-p-gp nil ,(rx bos "block" eos) ,(rx bos "catch_clause" eos))
+ grand-parent ,matlab-ts-mode--indent-level)
+
;; I-Rule: function a
;; x = 1;
;; <TAB> y = 2;
diff --git a/matlab.el b/matlab.el
index 6e721b4678..12f4e98011 100644
--- a/matlab.el
+++ b/matlab.el
@@ -1,6 +1,6 @@
;;; matlab.el --- major mode for MATLAB(R) dot-m files -*- lexical-binding: t
-*-
-;; Version: 7.2.0
+;; Version: 7.2.1
;; URL: https://github.com/mathworks/Emacs-MATLAB-Mode
;; SPDX-License-Identifier: GPL-3.0-or-later
diff --git a/tests/test-matlab-ts-mode-indent-files/indent_catch_with_comment.m
b/tests/test-matlab-ts-mode-indent-files/indent_catch_with_comment.m
new file mode 100644
index 0000000000..7a8ed2e61a
--- /dev/null
+++ b/tests/test-matlab-ts-mode-indent-files/indent_catch_with_comment.m
@@ -0,0 +1,7 @@
+% -*- matlab-ts -*-
+
+try
+ a = foo1();
+catch err %#ok
+ disp('catch');
+end
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_catch_with_comment_expected.m
b/tests/test-matlab-ts-mode-indent-files/indent_catch_with_comment_expected.m
new file mode 100644
index 0000000000..7a8ed2e61a
--- /dev/null
+++
b/tests/test-matlab-ts-mode-indent-files/indent_catch_with_comment_expected.m
@@ -0,0 +1,7 @@
+% -*- matlab-ts -*-
+
+try
+ a = foo1();
+catch err %#ok
+ disp('catch');
+end
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_catch_with_comment_expected_msgs.m
b/tests/test-matlab-ts-mode-indent-files/indent_catch_with_comment_expected_msgs.m
new file mode 100644
index 0000000000..fcce5b1f43
--- /dev/null
+++
b/tests/test-matlab-ts-mode-indent-files/indent_catch_with_comment_expected_msgs.m
@@ -0,0 +1,7 @@
+% -*- matlab-ts -*- % <{Matched rule: ((lambda (node parent _bol &rest _)
(and node (not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
+
+try % <{Matched rule: ((lambda (node parent _bol &rest _) (and node (not
(string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
+ a = foo1(); % <{Matched rule: ((node-is
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
parent 4)}>
+catch err %#ok % <{Matched rule: ((node-is
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\)?_clause\\)\\|nd\\)\\)\\'")
parent 0)}>
+ disp('catch'); % <{Matched rule: ((n-p-gp nil "\\`block\\'"
"\\`catch_clause\\'") grand-parent 4)}>
+end % <{Matched rule: ((node-is
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\)?_clause\\)\\|nd\\)\\)\\'")
parent 0)}>
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_comment_after_prop_expected_msgs.m
b/tests/test-matlab-ts-mode-indent-files/indent_comment_after_prop_expected_msgs.m
index 9ccfbacce7..5ad543872f 100644
---
a/tests/test-matlab-ts-mode-indent-files/indent_comment_after_prop_expected_msgs.m
+++
b/tests/test-matlab-ts-mode-indent-files/indent_comment_after_prop_expected_msgs.m
@@ -72,7 +72,7 @@ classdef indent_comment_after_prop < handle % <{Matched
rule: ((lambda (node pa
% comment % <{Matched rule: ((parent-is
"\\`block\\'") parent 0)}>
catch ME % <{Matched rule: ((node-is
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\)?_clause\\)\\|nd\\)\\)\\'")
parent 0)}>
disp('caught error'); % <{Matched rule: ((node-is
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
parent 4)}>
- % comment % <{Matched rule: ((parent-is
"\\`block\\'") parent 0)}>
+ % comment % <{Matched rule: ((n-p-gp nil
"\\`block\\'" "\\`catch_clause\\'") grand-parent 4)}>
end % <{Matched rule: ((node-is
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\)?_clause\\)\\|nd\\)\\)\\'")
parent 0)}>
end % <{Matched rule: ((node-is
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\)?_clause\\)\\|nd\\)\\)\\'")
parent 0)}>