branch: externals/matlab-mode
commit 8b394ca57993c81afcd856819f9fca3d4354b818
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>

    matlab-ts-mode: fix indent after abstract methods
---
 matlab-ts-mode.el                                  |  14 +-
 .../indent_classdef_abs_methods.m                  |  10 ++
 .../indent_classdef_abs_methods_expected.org       | 154 +++++++++++++++++++++
 3 files changed, 169 insertions(+), 9 deletions(-)

diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el
index b76a3fe5b9..13db2592c3 100644
--- a/matlab-ts-mode.el
+++ b/matlab-ts-mode.el
@@ -1912,13 +1912,17 @@ Example:
      ((n-p-gp nil ,(rx bos "\n" eos) ,(rx bos (or "function_definition") eos))
       grand-parent ,#'matlab-ts-mode--set-function-indent-level)
 
-
      ;; I-Rule: constructs within classdef or function's.
      ((node-is ,(rx bos (or "arguments_statement" "block" "enumeration" "enum" 
"methods" "events"
                             "function_definition" "property" "properties")
                     eos))
       parent ,matlab-ts-mode--indent-level)
 
+     ;; I-Rule: classdef abstract methods
+     ;; See: 
tests/test-matlab-ts-mode-indent-xr-files/indent_classdef_abs_methods.m
+     ((n-p-gp nil ,(rx bos "\n" eos) ,(rx bos "function_signature" eos)) 
grand-parent 0)
+     ((n-p-gp ,(rx bos "\n" eos) ,(rx bos "function_signature" eos) nil) 
parent 0)
+
      ;; I-Rule: items in blocks
      ((n-p-gp nil ,(rx bos "property" eos) ,(rx bos "properties" eos))
       grand-parent ,matlab-ts-mode--indent-level)
@@ -3209,14 +3213,6 @@ so configuration variables of that mode, do not affect 
this mode.
     ;; Activate MATLAB script ";; heading" matlab-sections-minor-mode if needed
     (matlab-sections-auto-enable-on-mfile-type-fcn 
(matlab-ts-mode--mfile-type))
 
-    ;; TODO indent
-    ;;      classdef Shape
-    ;;          methods(Abstract)
-    ;;              [area, desc] = getArea(obj)
-    ;;              ^                                   <== RET/TAB to here
-    ;;          end
-    ;;      end
-    ;;
     ;; TODO indent on incomplete code
     ;;      c1 = { ...
     ;;             'foo', ...                      <== RET/TAB to here
diff --git 
a/tests/test-matlab-ts-mode-indent-xr-files/indent_classdef_abs_methods.m 
b/tests/test-matlab-ts-mode-indent-xr-files/indent_classdef_abs_methods.m
new file mode 100644
index 0000000000..3d3e35c78a
--- /dev/null
+++ b/tests/test-matlab-ts-mode-indent-xr-files/indent_classdef_abs_methods.m
@@ -0,0 +1,10 @@
+% -*- matlab-ts -*-
+
+classdef indent_classdef_abs_methods
+    methods(Abstract)
+        % (t-utils-xr "C-n" "C-e" "C-m" "C-a" "C-i" "C-a" "C-k" "C-o" "C-i" 
(insert "%comment"))
+        [area, desc] = getArea(obj)
+    end
+end
+
+%(t-utils-xr (t-utils-xr-print-code (point-min) (point-max)))
diff --git 
a/tests/test-matlab-ts-mode-indent-xr-files/indent_classdef_abs_methods_expected.org
 
b/tests/test-matlab-ts-mode-indent-xr-files/indent_classdef_abs_methods_expected.org
new file mode 100644
index 0000000000..5ec3590f8e
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-indent-xr-files/indent_classdef_abs_methods_expected.org
@@ -0,0 +1,154 @@
+#+startup: showall
+
+* Executing commands from indent_classdef_abs_methods.m:5:10:
+
+  (t-utils-xr "C-n" "C-e" "C-m" "C-a" "C-i" "C-a" "C-k" "C-o" "C-i" (insert 
"%comment"))
+
+- Invoking      : "C-n" = next-line
+  Start point   :  177
+  Moved to point:  213
+  : 6:35:         [area, desc] = getArea(obj)
+  :                                          ^
+  No buffer modifications
+
+- Invoking      : "C-e" = move-end-of-line
+  Start point   :  213
+  No point movement
+  No buffer modifications
+
+- Invoking      : "C-m" = newline
+  Start point   :  213
+  Moved to point:  222
+  : 7:8:         
+  :              ^
+  Buffer modified:
+  #+begin_src diff
+--- start_contents
++++ end_contents
+@@ -4,6 +4,7 @@
+     methods(Abstract)
+         % (t-utils-xr "C-n" "C-e" "C-m" "C-a" "C-i" "C-a" "C-k" "C-o" "C-i" 
(insert "%comment"))
+         [area, desc] = getArea(obj)
++        
+     end
+ end
+ 
+  #+end_src diff
+
+- Invoking      : "C-a" = move-beginning-of-line
+  Start point   :  222
+  Moved to point:  214
+  : 7:0:         
+  :      ^
+  No buffer modifications
+
+- Invoking      : "C-i" = indent-for-tab-command
+  Start point   :  214
+  Moved to point:  222
+  : 7:8:         
+  :              ^
+  No buffer modifications
+
+- Invoking      : "C-a" = move-beginning-of-line
+  Start point   :  222
+  Moved to point:  214
+  : 7:0:         
+  :      ^
+  No buffer modifications
+
+- Invoking      : "C-k" = kill-line
+  Start point   :  214
+  No point movement
+  Buffer modified:
+  #+begin_src diff
+--- start_contents
++++ end_contents
+@@ -4,7 +4,6 @@
+     methods(Abstract)
+         % (t-utils-xr "C-n" "C-e" "C-m" "C-a" "C-i" "C-a" "C-k" "C-o" "C-i" 
(insert "%comment"))
+         [area, desc] = getArea(obj)
+-        
+     end
+ end
+ 
+  #+end_src diff
+
+- Invoking      : "C-o" = open-line
+  Start point   :  214
+  No point movement
+  Buffer modified:
+  #+begin_src diff
+--- start_contents
++++ end_contents
+@@ -4,6 +4,7 @@
+     methods(Abstract)
+         % (t-utils-xr "C-n" "C-e" "C-m" "C-a" "C-i" "C-a" "C-k" "C-o" "C-i" 
(insert "%comment"))
+         [area, desc] = getArea(obj)
++
+     end
+ end
+ 
+  #+end_src diff
+
+- Invoking      : "C-i" = indent-for-tab-command
+  Start point   :  214
+  Moved to point:  222
+  : 7:8:         
+  :              ^
+  Buffer modified:
+  #+begin_src diff
+--- start_contents
++++ end_contents
+@@ -4,7 +4,7 @@
+     methods(Abstract)
+         % (t-utils-xr "C-n" "C-e" "C-m" "C-a" "C-i" "C-a" "C-k" "C-o" "C-i" 
(insert "%comment"))
+         [area, desc] = getArea(obj)
+-
++        
+     end
+ end
+ 
+  #+end_src diff
+
+- Invoking      : (insert "%comment")
+  Start point   :  222
+  Moved to point:  230
+  : 7:16:         %comment
+  :                       ^
+  Buffer modified:
+  #+begin_src diff
+--- start_contents
++++ end_contents
+@@ -4,7 +4,7 @@
+     methods(Abstract)
+         % (t-utils-xr "C-n" "C-e" "C-m" "C-a" "C-i" "C-a" "C-k" "C-o" "C-i" 
(insert "%comment"))
+         [area, desc] = getArea(obj)
+-        
++        %comment
+     end
+ end
+ 
+  #+end_src diff
+
+* Executing commands from indent_classdef_abs_methods.m:11:1:
+
+  (t-utils-xr (t-utils-xr-print-code (point-min) (point-max)))
+
+- Invoking      : (t-utils-xr-print-code (point-min) (point-max))
+  Start point   :  305
+  No point movement
+  standard-output:
+  #+begin_src matlab-ts
+% -*- matlab-ts -*-
+
+classdef indent_classdef_abs_methods
+    methods(Abstract)
+        % (t-utils-xr \"C-n\" \"C-e\" \"C-m\" \"C-a\" \"C-i\" \"C-a\" \"C-k\" 
\"C-o\" \"C-i\" (insert \"%comment\"))
+        [area, desc] = getArea(obj)
+        %comment
+    end
+end
+
+%(t-utils-xr (t-utils-xr-print-code (point-min) (point-max)))
+  #+end_src
+  No buffer modifications

Reply via email to