Commit graph

36 commits

Author SHA1 Message Date
Eric Ludlam 083a5e9e05 matlab-syntax.el:
(matlab-block-comment-start-re, matlab-block-comment-end-re)
(matlab-ltype-block-comment-start, matlab-ltype-block-comment-end)
(matlab-block-comment-bounds):
DELETED - no longer used.

matlab.el:
(matlab-mode-map): Re-arrange the map.
Delete bindings for return and c-j (use default)
Add comments and build sections.
(matlab-mode): Update comments.
Add electric-indent-functions setting.
Remove matlab-comment-indent as a setting (use nil)
(matlab-return-function, matlab-return, matlab-plain-ret)
(matlab-indent-after-ret, matlab-indent-end-before-ret)
(matlab-semicolon-on-return, matlab-indent-before-ret)
(matlab-linefeed):
DELETED - use default 'newline' and electric indents instead.
(matlab-electric-indent-function):
NEW - auto-reindent when finishing typing end,
else, case, and a few other things.
(matlab-electric-comment):
Re-write to use new APIs from matlab-scan.el.
This enabled deletion of block comment stuff from matlab-syntax.el.
(matlab-comment-line-break-function):
Remove use of 'matlab-indent-line'.
(matlab-comment-indent): Delete (see change in matlab-mode)

tests/metest.el:
Stop using `matlab-block-comment-bounds'.  Replace with new API call.
2021-04-09 21:31:53 -04:00
Eric Ludlam 84dab231ea matlab.el:
(matlab-indent-function-body, matlab-functions-have-end):
Make safe local variable (needed in tests.)

(matlab-line-count-open-blocks, matlab-line-count-closed-blocks):
DELETE - replaced by ...
(matlab-line-count-block-change):  New.
Return + or - num based on num of opened or closed blocks that
don't cancel eachother out.  Cuts keyword search on line in half.

(matlab-next-line-indentation): Use `matlab-line-count-block-change'
replacing old calls.
Simplify how functions w/ no indent works.
Simplify indent based on indenting block starts and ends.
Simplify number of local variables.

tests/metest.el:
Add new test file for detect and indent.

tests/mfuncnofuncindent.m:
New file with functions with ends but no indent.
Setting w/ local variable.
Verify this mode works.
2021-04-02 22:28:15 -04:00
Eric Ludlam 21b33abd51 matlab-complete.el:
(matlab-find-recent-variable-list): Use new search APIs for keyword
searches.
Fix some misc bugs.
(matlab--complete-compute-search-functions):
New - pulled from below:
(matlab-complete-symbol-local):
Remove code for deriving which functions to use.
Pulled out to support testing.

matlab.el:
(matlab-mcos-innerblock-regexp, matlab-mcos-regexp, matlab-block-beg-pre-if)
(matlab-block-beg-pre-no-if, matlab-block-beg-pre): DELETED

tests/metest.el:
(matlab-complete): New require
(metest-all-syntax-tests): Move stuff around.  Add metest-complete-test.
(met-complete-files, met-complete-tools, metest-complete-test): NEW

tests/complete.m:
New file for testing local completion stuff.
2021-03-27 13:58:07 -04:00
Eric Ludlam 67eb90e872 matlab-scan.el:
(matlab-line-declaration-p): Fix doc.
(matlab-line-first-word-text): New.

matlab.el:
(matlab-defun-regex): DELETED.
(matlab-guess-script-type): Replace use of matlab-defun-regex
with new api style navigation.
(matlab-guess-function-indentation): New way to guess
if a file should have indentation in function body.
(matlab-really-gaudy-font-lock-keywords): for tranpose,
use builtin-face like other operators.
(matlab-mode): When matlab-indent-function-body is 'guess
use new function above.
(matlab-find-prev-code-line, matlab-find-prev-line)
(matlab-prev-line, matlab-valid-end-construct-p): DELETED.
(matlab-mode-vf-block-matches-backward): DELETED

mlint.el:
(mlint-fix-entry): Use new api instead of
matlab-find-prev-code-line.

tests/metest.el:
In end detect test, turn `matlab-indent-function-body' to 'guess.
In test, also validate what the indent value is.
Put value for indent-function-body back to mw standard when done.

tests/empty.m, tests/mclass.m, tests/mfuncends.m
tests/mfuncnoends.m, tests/mfuncnoendblock.m:
Add indent exptect value to file

tests/mfuncnoendindent.m:
New file for testing endless function that should be indented.
2021-03-26 21:05:11 -04:00
Eric Ludlam 4c389c08fa matlab.el:
(matlab-math-face): New
(matlab-simulink-keyword-face): Inherit from builtin, not type.
(matlab-ignored-comment-face): Remove height change, too disruptive.
(matlab-keyword-list, matlab-keyword-first-on-line-list):
DELETED (now in matlab-scan.el)
(matlab-hg-primitives-list): New name, many new words.
(matlab-constants-keyword-list): Add flintmax.
(matlab-font-lock-regexp-opt): Use symbol ends.
(matlab-font-lock-mcos-keyword-match):
After match, skip over attribute list.  Needed for anchored matchers.
(matlab-font-lock-anchor-set-end-limit): Don't change match data.
(matlab-font-lock-anchor-variable-match):
Update regex to be more robust.
Always move endpoint to EOL.
(matlab-basic-font-lock-keywords):
Use symbol end matchers \\_< and \\_> where needed.
Delete crufty old comments.
(matlab-really-gaudy-font-lock-keywords):
Add more logical things and use built-in face on them.

tests/metest.el:
Add new instrumentation options for new faces used by font lockers.

tests/blocks.m, tests/mclass.m:
Fixup for changes in font lock faces used.
2021-03-26 18:52:45 -04:00
Eric Ludlam 2435bf1000 matlab-syntax.el:
(matlab-syntax-commanddual-functions): Add cd and colormap.
(matlab--scan-line-for-command-dual): Make sure case-fold-search set
so we don't match cmd dual if user messes w/ capitalization.
(matlab--font-lock-syntactic-face): Add support for ignored comment face.
(matlab-cursor-comment-string-context): Improve help.

matlab.el:
(matlab-ignored-comment-face): New

tests/metest.el:
(metest-comment-string-syntax-test):
Add ignored comment support.
Add 'regular' code support (ie - not string or comment)
(met-kw-font-alist):
Add ignored comment support.

tests/fontlock.m:
Add tests for ignored comment face.

tests/stringtest.m:
Add ignored cmd dual cases.
Add ignored comment detection and tests.
2021-03-26 12:46:34 -04:00
Eric Ludlam 9a8784af2a matlab-scan.el:
(matlab-previous-code-line): In case of no comments, also
hand skip over whitespace charts.

tests/metest.el:
Force empty lines to have no spaces, other lines stay the same.
This will exercise bug found above.

tests/indents.m:
Fix mlint error.
2021-03-25 19:02:27 -04:00
Eric Ludlam 5c6ef4b9c5 matlab-scan.el:
(matlab-kwt-*): New regex caches.
(matlab-keyword-regex): Update to use new caches.
(matlab-compute-line-context-lvl-1): Support %^ ignore comment type
(matlab--scan-next-keyword): New helper fcn.
(matlab-re-search-keyword-forward): Add extra BONUSTEST input.
Used to filter out some kinds of hints by matlab--scan-next-keyword.

matlab.el:
(matlab-font-lock-basic-keyword-match)
(matlab-font-lock-vardecl-keyword-match)
(matlab-fl-anchor-keyword)
(matlab-font-lock-args-keyword-match)
(matlab-font-lock-extend-region)
(matlab-font-lock-anchor-set-end-limit)
(matlab-font-lock-anchor-clear-end-limit)
(matlab-font-lock-anchor-variable-match):
New font lock support features.
(matlab-basic-font-lock-keywords)
(matlab-file-basic-font-lock-keywords)
(matlab-function-font-lock-keywords)
(matlab-file-class-font-lock-keywords):
Use above new font lock keyword matchers.
(matlab-mode): Setup font lock extend region feature.

tests/metest.m:
(met-fontlock-files): Add blocks.m

tests/blocks.m, tests/fontlock.m, tests/mclass.m:
Add new font lock testing instrumentation.
2021-03-24 21:43:56 -04:00
Eric Ludlam d7d0766937 matlab-syntax.el:
(matlab--font-lock-syntactic-face): Add pragma face support.

matlab.el:
(matlab-string-start-regexp): Delete (unused)
(matlab-font-lock-extend-region): Delete.
block comments now supported natively.
(matlab-pragma-face): New
(matlab-basic-font-lock-keywords):
Delete pragma face support
end & ref keyword regex tweak to use \\_>
(matlab-mode): Don't setup font-lock-extend-region

tests/metest.el:
(met-kw-font-alist):
Add some new face keys to test.
(met-fontlock-files): Add fontlock.m
(metest-fontlock-test): Tweak how multi-fonts on one spot test.

tests/fontlock.m:
New suite of tests.
tests/mclass.m:
Add some more font lock tests.
2021-03-23 19:23:08 -04:00
Eric Ludlam a29adf40af matlab-scan.el:
(matlab--valid-mcos-keyword-point):
When verifying an mcos keyword, be sure to travel to beginning of
command before identifying if it is a class or end.

tests/mclass_cont.m:
New test for above.

tests/metest.el:
Add mclass_cont.m as an indentation test.
2021-03-22 14:10:55 -04:00
Eric Ludlam daa3569bc7 tests/metest.el:
(met-kw-font-alist): New
(metest-fontlock-test): Add implementation

tests/mpclass.m:
Instrument with font lock testing cookies.
2021-03-21 11:29:23 -04:00
Eric Ludlam 276e813831 matlab.el:
(matlab-mode-vf-block-matches-forward): If this buffer has bad
list syntax, don't bother doing any work.

metest.el:
(metest-comment-string-syntax-test):
Add font lock testing to all found comments and strings.

(met-fontlock-files, metest-fontlock-test):
New but empty - TODO to impl this.
2021-03-21 10:19:10 -04:00
Eric Ludlam 81cc7718eb matlab-scane.el:
(matlab--buffer-block-tree): Delete
(matlab--scan-block-forward):
Handle case when `matlab-functions-have-end' is false.
(matlab-re-search-keyword-forward,matlab-re-search-keyword-backward):
Handle bounds correctly before restarting a scan.
(matlab-scan-before-change-fcn):
Only clear cached items AFTER the change.

matlab.el:
(matlab-in-command-restriction, matlab-with-current-command)
(matlab-lattr-local-end): DELETE
(matlab-backward-sexp, matlab-forward-sexp):
Reimplement using matlab--scan-block-forward/backward.
(matlab-lattr-block-cont, matlab-lattr-block-close):
Remove narrowing to current command, and use new search utils with bounds.
(matlab-lattr-middle-block-cont): Comment out

tests/metest.m:
(metest-sexp-traversal-test variable): better name.
(metest-sexp-traversal-test): Use new `matlab--scan-block-forward' / backward
instead of orig fcns.

tests/blocks.m:
Tweak a few test points to make them more challenging.
tests/continuations.m:
Added test with continuation, but disabled the problem.
tests/indents.m:
Brought in problem lines that break array sexp w/ ' in continuation
tests/mfuncnoend.m:
Fix whitespace.
tests/mfuncnoendblock.m:
Fix mlint warnings.
2021-03-19 23:28:51 -04:00
Eric Ludlam e0a7d52385 matlab-scan.el:
(matlab-compute-line-context): Don't change the match data.
(matlab-scan-end-of-command): New

matlab-syntax.el:
Doc string fixes.

matalb.el:
(matlab-find-prev-code-line): Now uses matlab-scan-beginning-of-command
instead of old version.
(matlab-with-current-command): Now uses matlab-scan-beginning-of-command AND
matlab-scan-end-of-command to build the narrowed region.
(matlab-cursor-on-valid-block-start): Make this immune to changes in
match-data from various conditions in the cond statement.
Use new matlab-scan-beginning-of-command instead of old version.
(matlab-beginning-of-command): Now use matlab-scan-beginning-of-command
as default impl.  Delete this fcn later.
(matlab-lattr-block-close):
Track original starting pos better, grab line context  after moving to start.

tests/metest.el:
Include new continuations.m test file.

tests/continuations.m:
New test file

tests/indents.m:
Move a couple tests into continuations.m
2021-03-18 21:48:16 -04:00
Eric Ludlam 9d41e46c98 matlab-scan.el:
Make accessing keywords easier.
(matlab-keyword-p): New
(matlab-compute-line-context-lvl-1): Use above.

matlab-syntax.el:
Support command dual as a string in the syntax tabe.
(matlab--command-dual-syntax): New syntax type
(matlab--syntax-propertize): Call scanner for command-dual.
(matlab--scan-line-for-command-dual): New.
(matlab--font-lock-syntactic-face):
Detect command dual and provide that face.
Detect cellbreak comments and provide that face.
(matlab-cursor-comment-string-context):
Also detect commanddual strings, and return that status.

matlab.el:
Revamp font lock keywords to take advantage of updates in
`matlab--font-lock-syntactic-face' updates, and to just
lean into use of defface.
(matlab-show-mlint-warnings, matlab-highlight-cross-function-variables):
Make safe local variables.
(matlab-commanddual-string-face): New variable.
(matlab-font-lock-adjustments): Delete as a function and hook setup.
Replace with just the classic defface calls, but cleaned up to
also :inherit from base faces.
(matlab-file-basic-font-lock-keywords): Remove cell break code.

tests/metest.el:
Add tests for commanddual strings.
(metest-comment-string-syntax-test):
Add ability to test for commanddual strings.

tests/stringtest.m:
Add some command dual examples.
2021-03-15 21:52:54 -04:00
Eric Ludlam 39f1178516 metest.el:
(metest-indents-randomize-files):
Force matlab-mode to re-run so script type is recomputed after
extra indent added.

mfunspacey.m:
New file for script type detection tests.
2021-03-15 13:52:16 -04:00
Eric Ludlam 6fe7da0a62 tests/metest.el
(metest-all-syntax-tests): Force files used for intenting to be
pre-spaced incorrectly.
(metest-condition-case-error-msg): Fix how caught errors are thrown.
(met-indents-files): Add mfuncnoendblock.m
(metest-indents-randomize-files): New
Not really random.
(metest-error): Add a buffer excerpt before throwing an error.

tests/indents.m, tests/mfuncends:
Added more indent tests.
tests/mfuncnoendblock.m:
Add more content.
Enable for use in indentation test.
2021-03-14 19:28:48 -04:00
Eric Ludlam fb136a19f2 tests/metest.el:
(matlab-all-syntax-tests):
Reset the scanner cache hit stats and print when done.
(metest-test-error): Var flag.
(mecondition-case-error-msg):
When test flag set, forward the error along.
(metest-error): Set metest-test-error flag to pass errors through.

(metest-indent-counts): New
(metest-indents-test): Remove core test into new fcn.
Now set matlab--change-indentation-override to our fcn for tracking.
Now call matlab-indent-region with flags for testing.
(metest-indents-test-hook-fcn): New fcn that does the test
on each line from indent-region after indentation is compuated.
2021-03-14 00:12:36 -05:00
Eric Ludlam cf945dedd1 tests/metest.el:
Improve control of debugging output by enabling for test script code,
but disabling while running individual tests.
Tests will catch the error, and show the line in the file where
the test failed.
2021-03-12 22:08:41 -05:00
Eric Ludlam ba7df01197 tests/metest.el:
Revise to move all message output outside what is being timed.
Move looping over files outside the test functions.
Combine timings from one test point to one number to be recorded.
Reduce # of lines output during test running.
2021-03-12 19:43:05 -05:00
Eric Ludlam e57ff3e005 metest.el:
(metest-error): Convert back to error.
2021-03-10 19:54:04 -05:00
Eric Ludlam 27e654c9c0 tests/metest.el:
(metest-all-syntax-tests): Add timing instrumentation.
(metest-condition-case-error-msg): New utility.
(metest-indents-test): Wrap indent computation
in `metest-condition-case-error-msg'.
(metest-log-file): New cofig
(metest-log-init, metest-shorten, metest-log-write)
(metest-log-report, metest-timeint): New.
2021-03-10 19:50:50 -05:00
Eric Ludlam b450fe1685 matlab.el:
(matlab-ltype-comm): Make robust to block comment start,
where bounds returns false when on start.  Need to also check
for the start of a block comment.
(matlab--maybe-yes-or-no-p): New
(matlab-calcuate-indentation-1):
Use above instead of yes-or-no-p.

metest.el:
(met-end-detect-files): Add mfuncnoendblock.m
mfuncends.m:
Fix expected indentation numbers for continued arrays.
mfuncnoendblock.m:
New.
2021-03-08 08:09:06 -05:00
Eric Ludlam 04ae9b1249 tests/metest.el:
(metest-error): New function
Adds file / lineno to test errors so you can jump to the right location quickly.
(metest-*-test): Update all functions to use `metest-error'.
2021-03-07 11:54:38 -05:00
Eric Ludlam 134800317a matlab.el:
(matlab-lattr-block-close): After narrowing buffer,
got to eol, not max - as we had to expand the narrowed region
to handle special syntax chars on eol.

metest.el:
(metest-all-syntax-tests): Add ...
(metest-end-detect-test): New test
(met-end-dect-files): New Var
(metest-comment-string-syntax-test)
(metest-sexp-counting-test, metest-sexp-traversal-test)
(metest-indents-test, metest-parse-test):
Use new `metest-find-file' for loading in files.
(met-indents-files): Add mfuncends.m

tests/empty.m:
tests/mfuncends.m:
tests/mfuncnoend.m:
New test files

tests/stringtest.m:
tests/mclass.m:
Add end-detect expected value cookies.
2021-03-07 10:56:52 -05:00
Eric Ludlam f0457f228b matlab.el:
Delete large swaths of code related to syntax tables which
has moved to matlab-syntax.el.
(matlab-syntax): New require.
(matlab-mode-syntax-table, matlab-mode-special-syntax-table):
Moved to matlab-syntax.el
(matlab-font-lock-string-start-regexp)
(matlab-font-lock-string-and-comment-start-regexp)
(matlab-test-allstring-comment-match)
(matlab-font-lock-allstring-comment-match-normal):
No longer needed.  Deleted.
(matlab-font-lock-extend-region):
Switch to use matlab-block-comment-bounds.
(matlab-block-comment-*-re, matlab-ltype-block-comment-*):
Moved to matlab-syntax.el
(matlab-basic-font-lock-keywords):
Delete comment and string highlighting.
(matlab-basic-file-font-lock-keywords):
Delete block comment highlighting.
(matlab-mode): Delete all code related to syntax stuff.
Add call to `matlab-syntax-setup'.
Remove `after-change-functions' - no longer needed to handle block comments.
Enable syntax table font-locking comments/strings.
Remove special forward-sexp-function.
(matlab-navigation-syntax, matlab-up-list):
Moved to matlab-syntax.el
(matlab-with-current-command): Extend restricted region 1 char
past eol to include newline - needed for end-of-comment.
(matlab-backward-up-string-or-comment): Fix ellipsis spelling.
Only backup 1 char, reverse scan goes to beginning, not end of ...
(matlab-move-list-sexp-internal)
(matlab-move-simple-sexp-backward-internal)
(matlab-move-simple-sexp-internal)
Deleted.
(matlab-backward-sexp, matlab-forward-sexp)
(matlab-beginning-of-command, matlab-ltype-comm)
(matlab-debug-block-comm)
(matlab-electric-block-comment)
(matlab-show-paren-or-block)
(matlab-mode-vf-block-matches-forward):
Rename matlab-ltype-block-comm to matlab-block-comment-bounds.
(matlab-ltype-block-comm-bounds, matlab-ltype-block-comm-lastcompute)
(matlab-change-funtion, matlab-ltype-block-comm, matlab-ltype-block-comm-1):
Deleted.
(matlab-ltype-block-comm-at-*)
(matlab-cursor-comment-string-context)
(matlab-cursor-in-string-or-comment)
(matlab-cursor-in-comment)
(matlab-cursor-in-string):
Moved to matlab-syntax.el
(matlab-calculate-indentation-1):
Replace old block comment stuff with new `matlab-block-comment-bounds'.
Stop using old cache, just compute bounds once and use it.

tests/mtest.el:
Rename matlab-ltype-block-comm to matlab-block-comment-bounds.
Fix spelling of ellipsis
Add a little more debugging output.

Makefile, Project.ede:
Add matlab-syntax.el

tests/stringtest.m:
Add some blank lines to protect against indentation.
Fix indentation.
2021-03-07 00:14:21 -05:00
Eric Ludlam a746ccc931 matlab.el:
(matlab-file-basic-font-lock-keywords)
(matlab-file-lass-font-lock-keywords):
first-on-line keywords must be followed by specific charts to be highlighted.
(matlab-find-prev-lie): Add optional input to ignore all comments.
(matlab-prev-line): fix doc to note it will stop on comments.
(matlab-cursor-on-vlaid-block-start):
When finding context for 'arguments', use `matlab-find-prev-line' instead
since arguments must be first actual code in the function.
(matlab-beginning-of-command): Wrap impl in save-match-data.
tests/Makefile:
Only run "shelltests" if not on windows.
tests/metest.el:
(met-sexp-test-files, metest-indents-files):  Add blocks.m
tests/blocks.m:
Add more cases abusing keywords as variables.
Instrument for testing with metest.el.
2021-02-27 16:52:31 -05:00
Eric Ludlam 8ac3cbf73b tests/metest.el:
(metest-comment-string-syntax-test):
Add block comment testing.
(met-sexptest-files): Remove indents.m, it had
not test points for sexp tests.

tests/stringtest.m:
Add a block comment and tests for detecting contents.
2019-12-17 17:57:56 -05:00
Eric Ludlam fe496763f3 Project.ede, Makefile:
Bring the tests directory into EDE.

mestest.el, mstest.el:
Fix byte compiler warnings.
2019-12-14 10:08:28 -05:00
Eric Ludlam c29f20a97b metest.el, metest.el:
Require matlab-load to get all the auto-loads in.
2019-11-28 18:13:25 -05:00
Eric Ludlam 3f0c078dd8 strings.m -> stringtest.m
Move to avoid warnings when CDing to this dir in MATLAB.
stringtest.m:
(met-stringtest-files): Use new name for string test file.
2019-11-23 16:58:23 -05:00
Eric Ludlam 64f2249b1e Add support for parsing MATLAB Classes to semantic-matlab.el
Add test file (mplass.m) and add parsing testing to metest.el.
2019-11-08 23:34:40 -05:00
Eric Ludlam a58df74bf1 metest.el - add metest-indents-test and support functions.
Tweak how all the test status msgs are printed to be better seperated.
Add indentation tokens to mclass.
Add new indents.m
2019-10-03 21:15:41 -04:00
Eric Ludlam d685f31c54 Add tests that verify more expressions, including those needed by show-paren-mode.
Tests the underlying function, not the show paren mode support.
2019-09-28 22:33:09 -04:00
Eric Ludlam 6a06906b2d Add tests to check sexp navigation with expressions.m, and new functions in metest.el.
Update strings.m to include strings with parens and brackets in them, also in cell arrays.
2019-09-26 21:42:55 -04:00
Eric Ludlam 83a7a4a8f4 Matlab emacs test suite.
Start with strings test.
2019-09-23 21:50:04 -04:00