branch: externals/matlab-mode
commit f0306d55b4f7c4e14377e69e41ed8236bd940df7
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>
treesit-mode-how-to.org: updated description of t-utils-xr
---
contributing/treesit-mode-how-to.org | 66 +++--
.../indent_xr_cell1.m | 14 +-
.../indent_xr_cell1_expected.org | 302 +++++++--------------
3 files changed, 151 insertions(+), 231 deletions(-)
diff --git a/contributing/treesit-mode-how-to.org
b/contributing/treesit-mode-how-to.org
index 21de63d73a..494e7bd23f 100644
--- a/contributing/treesit-mode-how-to.org
+++ b/contributing/treesit-mode-how-to.org
@@ -116,7 +116,7 @@ and run the test. The test will see there is no expected
baseline to compare aga
generate one for you and ask you to validate it. The expect baseline for
=file.lang= is
=file_expected.txt= and the contents of the =file_expected.txt= is of same
length of =file.lang=,
where each character's face is encoded in a single character. This makes it
very easy to lock down
-the behavior of font-lock without having to write lisp code to add the
expected rsults of the
+the behavior of font-lock without having to write lisp code to add the
expected results of the
test. The same test strategy is used for other aspects of our
=LANGUAGE-ts-mode=.
* Major Mode Conventions
@@ -239,8 +239,8 @@ You should now be able to use:
: M-x eval-buffer-fully
=M-x eval-buffer= will only re-evaluate defun definitions. It will not
reevaluate already
- defined =defvar=, =defvar-local=, and =defface= defintions. You can use =C-x
C-e= or =C-M-x= on
- each updated defintion to re-evaluate them. Alternatively, using
[[file:eval-buffer-fully.el]], you
+ defined =defvar=, =defvar-local=, and =defface= definitions. You can use
=C-x C-e= or =C-M-x= on
+ each updated definition to re-evaluate them. Alternatively, using
[[file:eval-buffer-fully.el]], you
can =M-x eval-buffer-fully=.
- =M-x LANGUAGE-ts-mode=
@@ -274,12 +274,12 @@ You should now be able to use:
1. ts-inspect-point
- : M-: (ts-inpsect-point)
+ : M-: (ts-inspect-point)
Display information about node at POSITION. \\
POSITION defaults to the current point.
Returns a string of the form:
- : Heirarchy:
+ : Hierarchy:
: #<treesit-node ROOT in 1-67>
: #<treesit-node PARENT in 37-62>
: #<treesit-node NODE in 61-62>
@@ -873,27 +873,49 @@ where =test-LANGUAGE-ts-mode-indent-xr.el= contains:
(t-utils-test-xr test-name lang-files)))
#+end_src
-An example =./tests/test-LANGUAGE-ts-mode-indent-xr-files/indent_test1.lang=
where =%= is starts a
-comment:
+An example =./tests/test-matlab-ts-mode-indent-xr-files/indent_cell1.m= where
=%= is starts a
+comment and =%{ ... %}= is a block comment:
-#+begin_example
- % -*- LANGUAGE-ts -*-
- % (t-utils-xr "C-a" "C-n" (insert "someVariable = {") "C-e" "C-m" (insert
"1234") "C-m" (insert "};") "C-m" (re-search-backward "^cell") (print
(buffer-substring-no-properties (point) (point-max))))
-#+end_example
+#+begin_src matlab-ts
+ % -*- matlab-ts -*-
-The execute and record function, =t-utils-xr= runs the Emacs commands which
creates below the
-comment line.
+ %{
+ (t-utils-xr
-#+begin_example
+ (re-search-forward "%}") "C-n"
+ (insert "someVariable = {") "C-m"
+ (insert "1234") "C-m"
+ (insert "};") "C-m"
+ (re-search-backward "^someVariable")
+ (t-utils-xr-print-code (point) (point-max))
+
+ )
+ %}
+#+end_src
+
+The execute and record function, =t-utils-xr= runs the Emacs commands. In this
example,
+we are re-playing the actions of typing
+
+#+begin_src matlab-ts
someVariable = {
1234
- }
-#+end_example
+ };
+#+end_src
+
+Any standard Emacs commands are allowed, e.g. "C-m" for Enter/Return (RET). In
addition, you can use
+=(t-utils-xr-print-code START-POINT END-POINT)= to capture the result of
running the commands in the
+baseline.
+
+The commands are executed and recorded. The recorded results are compared
against baseline:
+
+ : =./tests/test-matlab-ts-mode-indent-xr-files/indent_cell1_expected.org=
+
+If the baseline doesn't exist or result doesn't match the baseline, the test
fails and
+the following tilde file is created:
+
+ : =./tests/test-matlab-ts-mode-indent-xr-files/indent_cell1_expected.org~=
-The commands are recorded into
-=./tests/test-LANGUAGE-ts-mode-indent-xr-files/indent_test1_expected.org~= and
compared against
-baseline =indent_test1_expected.org=. If the baseline doesn't exist you are
asked to review
-=indent_test1_expected.org~= and rename it to indent_test1_expected.org if it
looks good.
+You can then rename the tilde file to =indent_cell1_expected.org= or fix the
code as needed.
** Sweep test: Indent
@@ -2201,5 +2223,5 @@ Install, using default branch
# LocalWords: lang utils Imenu LSP defun ELPA tuils setq SLIB libtree dylib
sexp xr defcusom
# LocalWords: defface EDebug ielm fontify Fontifying fontified defcustom
alist eos bol NPS prev BUF
# LocalWords: caar cdar bos dwim propertize ppss SPC reindent defadvice IMenu
imenu pred fn elec
-# LocalWords: funcall myfcn prin asdf repeat:nil ABI abi MSYS pacman gpg bobp
defclass
-# LocalWords: fontification lsp
+# LocalWords: funcall myfcn prin asdf repeat:nil ABI abi MSYS pacman gpg bobp
defclass docstring
+# LocalWords: fontification lsp numberp cdr keymap sudo nodejs npm linux gz
diff --git a/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_cell1.m
b/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_cell1.m
index 3c9aff68c1..7dc2cf0f94 100644
--- a/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_cell1.m
+++ b/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_cell1.m
@@ -1,2 +1,14 @@
% -*- matlab-ts -*-
-% (t-utils-xr "C-a" "C-n" (insert "cell1 = { ...") "C-e" "C-m" (insert
"{'one', ...") "C-m" (insert "'two'}, ...") "C-m" (insert "...") "C-m" (insert
"{'three'}") "C-m" (insert "};") "C-m" (re-search-backward "^cell") (print
(buffer-substring-no-properties (point) (point-max))))
+
+%{
+ (t-utils-xr
+
+ (re-search-forward "%}") "C-n"
+ (insert "someVariable = {") "C-m"
+ (insert "1234") "C-m"
+ (insert "};") "C-m"
+ (re-search-backward "^someVariable")
+ (t-utils-xr-print-code (point) (point-max))
+
+ )
+%}
diff --git
a/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_cell1_expected.org
b/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_cell1_expected.org
index 06fa19d476..c95da7017a 100644
--- a/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_cell1_expected.org
+++ b/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_cell1_expected.org
@@ -1,273 +1,159 @@
#+startup: showall
-* Executing commands from indent_xr_cell1.m:2:2:
+* Executing commands from indent_xr_cell1.m:4:2:
- (t-utils-xr "C-a" "C-n" (insert "cell1 = { ...") "C-e" "C-m" (insert
"{'one', ...") "C-m" (insert "'two'}, ...") "C-m" (insert "...") "C-m" (insert
"{'three'}") "C-m" (insert "};") "C-m" (re-search-backward "^cell") (print
(buffer-substring-no-properties (point) (point-max))))
+ (t-utils-xr
-- Invoking : "C-a" = move-beginning-of-line
- Start point : 300
- Moved to point: 21
- : 2:0: % (t-utils-xr "C-a" "C-n" (insert "cell1 = { ...") "C-e" "C-m"
(insert "{'one', ...") "C-m" (insert "'two'}, ...") "C-m" (insert "...") "C-m"
(insert "{'three'}") "C-m" (insert "};") "C-m" (re-search-backward "^cell")
(print (buffer-substring-no-properties (point) (point-max))))
- : ^
- No buffer modifications
+ (re-search-forward "%}") "C-n"
+ (insert "someVariable = {") "C-m"
+ (insert "1234") "C-m"
+ (insert "};") "C-m"
+ (re-search-backward "^someVariable")
+ (t-utils-xr-print-code (point) (point-max))
-- Invoking : "C-n" = next-line
- Start point : 21
- Moved to point: 301
- : 3:0:
- : ^
- No buffer modifications
+ )
-- Invoking : (insert "cell1 = { ...")
- Start point : 301
- Moved to point: 314
- : 3:13: cell1 = { ...
- : ^
- Buffer modified:
- #+begin_src diff
---- start_contents
-+++ end_contents
-@@ -1,2 +1,3 @@
- % -*- matlab-ts -*-
- % (t-utils-xr "C-a" "C-n" (insert "cell1 = { ...") "C-e" "C-m" (insert
"{'one', ...") "C-m" (insert "'two'}, ...") "C-m" (insert "...") "C-m" (insert
"{'three'}") "C-m" (insert "};") "C-m" (re-search-backward "^cell") (print
(buffer-substring-no-properties (point) (point-max))))
-+cell1 = { ...
-\ No newline at end of file
- #+end_src diff
-
-- Invoking : "C-e" = move-end-of-line
- Start point : 314
- No point movement
+- Invoking : (re-search-forward "%}")
+ Start point : 286
+ Moved to point: 289
+ : 14:2: %}
+ : ^
No buffer modifications
-- Invoking : "C-m" = newline
- Start point : 314
- Moved to point: 325
- : 4:10:
- : ^
- Buffer modified:
- #+begin_src diff
---- start_contents
-+++ end_contents
-@@ -1,3 +1,4 @@
- % -*- matlab-ts -*-
- % (t-utils-xr "C-a" "C-n" (insert "cell1 = { ...") "C-e" "C-m" (insert
"{'one', ...") "C-m" (insert "'two'}, ...") "C-m" (insert "...") "C-m" (insert
"{'three'}") "C-m" (insert "};") "C-m" (re-search-backward "^cell") (print
(buffer-substring-no-properties (point) (point-max))))
--cell1 = { ...
-\ No newline at end of file
-+cell1 = { ...
-+
-\ No newline at end of file
- #+end_src diff
+- Invoking : "C-n" = next-line
+ Start point : 289
+ Moved to point: 290
+ : 15:0:
+ : ^
+ No buffer modifications
-- Invoking : (insert "{'one', ...")
- Start point : 325
- Moved to point: 336
- : 4:21: {'one', ...
- : ^
+- Invoking : (insert "someVariable = {")
+ Start point : 290
+ Moved to point: 306
+ : 15:16: someVariable = {
+ : ^
Buffer modified:
#+begin_src diff
--- start_contents
+++ end_contents
-@@ -1,4 +1,4 @@
- % -*- matlab-ts -*-
- % (t-utils-xr "C-a" "C-n" (insert "cell1 = { ...") "C-e" "C-m" (insert
"{'one', ...") "C-m" (insert "'two'}, ...") "C-m" (insert "...") "C-m" (insert
"{'three'}") "C-m" (insert "};") "C-m" (re-search-backward "^cell") (print
(buffer-substring-no-properties (point) (point-max))))
- cell1 = { ...
--
-\ No newline at end of file
-+ {'one', ...
+@@ -12,3 +12,4 @@
+
+ )
+ %}
++someVariable = {
\ No newline at end of file
#+end_src diff
- Invoking : "C-m" = newline
- Start point : 336
- Moved to point: 348
- : 5:11:
- : ^
+ Start point : 306
+ Moved to point: 324
+ : 16:17:
+ : ^
Buffer modified:
#+begin_src diff
--- start_contents
+++ end_contents
-@@ -1,4 +1,5 @@
- % -*- matlab-ts -*-
- % (t-utils-xr "C-a" "C-n" (insert "cell1 = { ...") "C-e" "C-m" (insert
"{'one', ...") "C-m" (insert "'two'}, ...") "C-m" (insert "...") "C-m" (insert
"{'three'}") "C-m" (insert "};") "C-m" (re-search-backward "^cell") (print
(buffer-substring-no-properties (point) (point-max))))
- cell1 = { ...
-- {'one', ...
+@@ -12,4 +12,5 @@
+
+ )
+ %}
+-someVariable = {
\ No newline at end of file
-+ {'one', ...
-+
++someVariable = {
++
\ No newline at end of file
#+end_src diff
-- Invoking : (insert "'two'}, ...")
- Start point : 348
- Moved to point: 359
- : 5:22: 'two'}, ...
+- Invoking : (insert "1234")
+ Start point : 324
+ Moved to point: 328
+ : 16:21: 1234
: ^
Buffer modified:
#+begin_src diff
--- start_contents
+++ end_contents
-@@ -2,4 +2,4 @@
- % (t-utils-xr "C-a" "C-n" (insert "cell1 = { ...") "C-e" "C-m" (insert
"{'one', ...") "C-m" (insert "'two'}, ...") "C-m" (insert "...") "C-m" (insert
"{'three'}") "C-m" (insert "};") "C-m" (re-search-backward "^cell") (print
(buffer-substring-no-properties (point) (point-max))))
- cell1 = { ...
- {'one', ...
--
-\ No newline at end of file
-+ 'two'}, ...
-\ No newline at end of file
- #+end_src diff
-
-- Invoking : "C-m" = newline
- Start point : 359
- Moved to point: 370
- : 6:10:
- : ^
- Buffer modified:
- #+begin_src diff
---- start_contents
-+++ end_contents
-@@ -2,4 +2,5 @@
- % (t-utils-xr "C-a" "C-n" (insert "cell1 = { ...") "C-e" "C-m" (insert
"{'one', ...") "C-m" (insert "'two'}, ...") "C-m" (insert "...") "C-m" (insert
"{'three'}") "C-m" (insert "};") "C-m" (re-search-backward "^cell") (print
(buffer-substring-no-properties (point) (point-max))))
- cell1 = { ...
- {'one', ...
-- 'two'}, ...
-\ No newline at end of file
-+ 'two'}, ...
-+
-\ No newline at end of file
- #+end_src diff
-
-- Invoking : (insert "...")
- Start point : 370
- Moved to point: 373
- : 6:13: ...
- : ^
- Buffer modified:
- #+begin_src diff
---- start_contents
-+++ end_contents
-@@ -3,4 +3,4 @@
- cell1 = { ...
- {'one', ...
- 'two'}, ...
--
-\ No newline at end of file
-+ ...
-\ No newline at end of file
- #+end_src diff
-
-- Invoking : "C-m" = newline
- Start point : 373
- Moved to point: 384
- : 7:10:
- : ^
- Buffer modified:
- #+begin_src diff
---- start_contents
-+++ end_contents
-@@ -3,4 +3,5 @@
- cell1 = { ...
- {'one', ...
- 'two'}, ...
-- ...
+@@ -13,4 +13,4 @@
+ )
+ %}
+ someVariable = {
+-
\ No newline at end of file
-+ ...
-+
-\ No newline at end of file
- #+end_src diff
-
-- Invoking : (insert "{'three'}")
- Start point : 384
- Moved to point: 393
- : 7:19: {'three'}
- : ^
- Buffer modified:
- #+begin_src diff
---- start_contents
-+++ end_contents
-@@ -4,4 +4,4 @@
- {'one', ...
- 'two'}, ...
- ...
--
-\ No newline at end of file
-+ {'three'}
++ 1234
\ No newline at end of file
#+end_src diff
- Invoking : "C-m" = newline
- Start point : 393
- Moved to point: 404
- : 8:10:
- : ^
+ Start point : 328
+ Moved to point: 346
+ : 17:17:
+ : ^
Buffer modified:
#+begin_src diff
--- start_contents
+++ end_contents
-@@ -4,4 +4,5 @@
- {'one', ...
- 'two'}, ...
- ...
-- {'three'}
+@@ -13,4 +13,5 @@
+ )
+ %}
+ someVariable = {
+- 1234
\ No newline at end of file
-+ {'three'}
-+
++ 1234
++
\ No newline at end of file
#+end_src diff
- Invoking : (insert "};")
- Start point : 404
- Moved to point: 406
- : 8:12: };
- : ^
+ Start point : 346
+ Moved to point: 348
+ : 17:19: };
+ : ^
Buffer modified:
#+begin_src diff
--- start_contents
+++ end_contents
-@@ -5,4 +5,4 @@
- 'two'}, ...
- ...
- {'three'}
--
+@@ -14,4 +14,4 @@
+ %}
+ someVariable = {
+ 1234
+-
\ No newline at end of file
-+ };
++ };
\ No newline at end of file
#+end_src diff
- Invoking : "C-m" = newline
- Start point : 406
- Moved to point: 405
- : 9:0:
- : ^
+ Start point : 348
+ Moved to point: 347
+ : 18:0:
+ : ^
Buffer modified:
#+begin_src diff
--- start_contents
+++ end_contents
-@@ -5,4 +5,4 @@
- 'two'}, ...
- ...
- {'three'}
-- };
+@@ -14,4 +14,4 @@
+ %}
+ someVariable = {
+ 1234
+- };
\ No newline at end of file
-+ };
++ };
#+end_src diff
-- Invoking : (re-search-backward "^cell")
- Start point : 405
- Moved to point: 301
- : 3:0: cell1 = { ...
- : ^
+- Invoking : (re-search-backward "^someVariable")
+ Start point : 347
+ Moved to point: 290
+ : 15:0: someVariable = {
+ : ^
No buffer modifications
-- Invoking : (print (buffer-substring-no-properties (point) (point-max)))
- Start point : 301
+- Invoking : (t-utils-xr-print-code (point) (point-max))
+ Start point : 290
No point movement
standard-output:
- #+begin_example
-cell1 = { ...
- {'one', ...
- 'two'}, ...
- ...
- {'three'}
- };
- #+end_example
+ #+begin_src matlab-ts
+someVariable = {
+ 1234
+ };
+ #+end_src
No buffer modifications