branch: externals/matlab-mode
commit bcded10a406b4e5db816472c9ba5f75172d8b4f9
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>
README.org: update indent_example
---
README.org | 68 ++++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 40 insertions(+), 28 deletions(-)
diff --git a/README.org b/README.org
index 1b2c6def64..c5bfd0d811 100644
--- a/README.org
+++ b/README.org
@@ -94,57 +94,69 @@ With the optional matlab-ts-mode, you have
[[file:doc/matlab_code_indent.org][MA
Example:
#+begin_src matlab
- function out= indent_example( in1, ...
- input2)
- % INDENT_EXAMPLE - an indent example
- % which illustrates the MATLAB indent engine.
- arguments
- in1 = 10
- input2= 20;
- end
-
- mat = [100,2
- 3 400];
-
- s = struct( 'f1',1, ...
- 'otherField', in1+input2);
-
- if abs(sum(in1)) > 0
- out=s.f1/input2+ in1;
- else
- out = mat+in1 * 2;
- end
- end
+ function out= indent_example( in1, ...
+ input2)
+ % INDENT_EXAMPLE - an indent example
+ % This illustrates some of the capabilities of the MATLAB indent
engine.
+
+ arguments
+ in1 = 10
+ input2= 20;
+ end
+
+ mat = [100,2 300.2
+ 3 400,4];
+
+ s = struct( 'f1',1, ...
+ 'otherField', in1+input2);
+
+ a = 10; % comment for a
+ bLongVariable = [1.3 2,3 1 - 1 -1] ;% comment for b
+ cVar = a+bLongVariable * 2;
+
+ if abs(sum(in1)) > 0
+ out=s.f1/input2+ in1 -cVar;
+ else
+ out = mat+in1 * 2 -cVar;
+ end
+ end
#+end_src
Is indented to the following using ~C-x h~ and then ~C-M-\~ (or ~Edit ->
Select All~, then ~M-x
-indent-region~):
+indent-region~). Notice that in addition to adjusting the indent-level
(whitespace to the left),
+language element spacing has been standardized, statements have been aligned,
trailing comments have
+been aligned matrices have been aligned, missing comma's are added to arrays,
struct fields are
+aligned, etc.
#+begin_src matlab
function out = indent_example(in1, ...
input2)
% INDENT_EXAMPLE - an indent example
- % which illustrates the MATLAB indent engine.
+ % This illustrates some of the capabilities of the MATLAB indent engine.
+
arguments
in1 = 10
input2 = 20;
end
- mat = [100, 2
- 3, 400];
+ mat = [100, 2, 300.2
+ 3, 400, 4];
s = struct('f1' , 1, ...
'otherField', in1 + input2);
+ a = 10; % comment for a
+ bLongVariable = [1.3, 2, 3, 1 - 1, -1]; % comment for b
+ cVar = a + bLongVariable * 2;
+
if abs(sum(in1)) > 0
- out = s.f1 / input2 + in1;
+ out = s.f1 / input2 + in1 - cVar;
else
- out = mat + in1 * 2;
+ out = mat + in1 * 2 - cVar;
end
end
#+end_src
-
* Installation
1. Install the MATLAB package via [[https://melpa.org][MELPA]] or
[[https://elpa.gnu.org/][ELPA]]. MELPA contains the latest version. To install
from