Commit graph

530 commits

Author SHA1 Message Date
Eric Ludlam d0cda9be1d .gitignore:
Add .dat files (as generated by test build now.)
2021-03-10 21:33:17 -05:00
Eric Ludlam a948c123fe matlab-scan.el:
New algorithms for scanning MATLAB files for context.
2021-03-10 19:57:46 -05:00
Eric Ludlam 174f749e1f matlab-scan.el:
New algorithms for scanning MATLAB files for context.
matlab.el:
(matlab-mode-leave): Disable scanner in this buffer.
(matlab-mode): Enable scanner in this buffer.
(matlab-calculate-indentation-1):
Use `matlab-compute-line-context'.  Use output for comment detection.
Move block comment stuff first to maintain consistency with old behavior.

Project.ede, Makefile: Add matlab-scan.el
2021-03-10 19:57:23 -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 d96cb11f2f matlab.el:
(matlab-beginning-of-command):
Add hack to skip over multiple continued comments very fast.
This is a very specific optimization for many lines of comments.
2021-03-09 19:21:03 -05:00
Eric Ludlam 7f6f729fd3 matlab.el:
(matlab-calc-indent):
If current line detects we are in an array continuation, then
it is not necessary to compute next-line indentation from it's context
since you can't have if/end type code in there.
Also, array continuation detection is now very fast.
tests/indents.m:
Added a bunch of misc indenttion tests around nested arrays, cell arrays, etc.
2021-03-09 12:50:59 -05:00
Eric Ludlam 81f2cc0fd7 matlab.el:
(matlab-show-paren-or-block):
Use `syntax-class' instead of `car' for output of `syntax-after' to get the class.
This strips out high order bits to return the actual syntax #.
2021-03-09 12:06:03 -05:00
Eric Ludlam 7f9c905238 matlab.el:
(matlab-lattr-cont):
Replace old regexp based searching for ... with use of syntax-ppss,
and using it to find the char that starts the comment, and use to
verify an ellipsis.
2021-03-08 22:34:25 -05:00
Eric Ludlam 7a3e1e872b matlab-syntax.el:
(matlab-up-list): Remove restrict option

matlab.el:
(matlab-lattr-array-cont): Remove restrict option.
2021-03-08 22:08:38 -05:00
Eric Ludlam a8229c28e0 matlab.el:
(matlab-beginning-of-command): Remove searching for function/block to
restrict motion to.  The search and restrict just slowed down ppss.
(matlab-end-of-command): Remove optional input.
Stop restriting array-cont query.
(matlab-semicolon-on-return, matlab-mode-vf-quiesce-buffer):
Don't pass input to `matlab-end-of-command'.

matlab-syntax.el:
(matlab-up-list): Use `matlab-beginning-of-string-or-comment'
instead of asking for the string or commment bounds.
The beginning is part of ppss, but full bounds includes the end.
2021-03-08 21:58:25 -05:00
Eric Ludlam e9b66d32ab matlab.el:
(matlab-end-of-command):
In first check, swap order looking for array-cont first since it is faster.
(matlab-property-function, matlab-lattr-semantics): Deleted
(matlab-show-cursor-context): Deleted.

matlab-complete.el:
(matlab-lattr-semantics): Moved here from matlab.el
2021-03-08 18:50:01 -05:00
Eric Ludlam cc1a00548d matlab.el:
(beginning-of-command): Optimization for very long arrays
where user put ... inside the array.
ie - compute beginning of array bounds first, then look for
continuations.
2021-03-08 16:50:16 -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 83db249b97 matlab.el:
(matlab-uniquify-list): Move to matlab-complete.el
matlab-syntax.el:
(matlb-beginning-of-string-or-comment): New nav function
matlab-complete.el:
(matlab-uniquify-list): Moved here from matlab.el
(matlab-find-block-comments): Delete
(matlab-file-basic-font-lock-keywords): Remove ref to above.
(matlab-up-string-or-comment, matlab-backward-up-string-or-comment):
Delete.
(matlab-lattr-block-close):
Replace use of matlab-backward-up-string-or-comment with
matlab-beginning-of-string-or-comment.
2021-03-07 14:09:41 -05:00
Eric Ludlam 17cda9d9af matlab-cgen.el:
Found usage of font-lock function that has been deleted.
Mark this function as needing to be reimplemented.
2021-03-07 14:06:01 -05:00
Eric Ludlam 6126f39548 tests/indents.m:
(array_constant-decls): Add a bunch of ways to have arrays be indented.
2021-03-07 11:55:13 -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 8dafb13337 matlab-syntax.el
(matlab-up-list):
Replaced use of `up-list' when travelling backward.
Instead use `syntax-ppss' and the list of paren positions
to navigate upward while ignoring comments.
When travelling forward, use plain up-list with no
looping.
2021-03-07 11:20:51 -05:00
Eric Ludlam baa7c1210e tests/blocks.m:
Remove mlint warnings.
Full indent so blank-lines don't change on buffer indent.
2021-03-07 10:58:19 -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 6fe7a322d6 matlab-syntax.el:
(matlab-cursor-in-string-or-comment)
(matlab-cursor-in-comment, matlab-cursor-in-string):
Convert to use syntax-ppss directly.
2021-03-07 10:50:16 -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 4baad2b86c matlab-syntax.el:
New file - manage syntax table, and utilities that use the
syntax table for parsing strings, comments, and lists.
2021-03-06 23:56:15 -05:00
Eric Ludlam 1b0340b26b matlab.el:
(matlab-lattr-block-close): Account for commend imediately after
the end keyword.
tests/blocks.m:
(tightcomments): Add sample with comments tight to end
of every statement with indentation test cookies.
2021-03-06 13:05:29 -05:00
Eric Ludlam 66721488d9 tests/stringtest.m
Added ellipsis test marks in some places where they were missing.
2021-03-05 20:09:22 -05:00
Eric Ludlam 204fd79f1b matlab.el:
(matlab-valid-end-construct-p): an 'end' after a . is a field,
and not a valid block end.
(matlab-cursor-on-valid-block-start): any block after a . is a field,
and not a valid block start.

mlint.el:
(mlint-lm-missing-end::mlint-fix-entry): Fix too many close )

tests/blocks.m:
Add struct_stuff method to verify not indenting anything after a .

tests/stringtest.m:
Add an invalid block comment (all on one line) with test markers in it.
2021-03-05 16:59:06 -05:00
Eric Ludlam a8a7b7e73c mlint.el:
(mlint-error-id-fix-alist): Add ENDCT support.
(mlint-lm-missing-end::mlint-fix-entry):
Add support for adding end to functions without ends.
2021-03-05 16:42:43 -05:00
Eric Ludlam 02e9ea0a71 mlint.el:
Add autofix routines for missing ends, and missmatched file/class names.
(mlint-error-id-fix-alist): Add ENDCT2, FNDEF, and MCFIL support.
(mlint-lm-entry::mlint-fix-entry, mlint-lm-*::initialize-instance):
Fix all occurances of :AFTER with :after.
(mlint-lm-function-name): New class.
(mlint-lm-function-name::initialize-instance): New.
(mlint-lm-missing-end): New class.
(mlint-lm-missing-end::mlint-fix-entry): New.
2021-03-04 20:13:31 -05:00
Eric Ludlam 26875b9517 matlab.el:
(matlab-block-end-pre): Reverse choice of regex used if functions have end.
This appears to have been backwards for a very long time.
(tests/blocks.m, tests/indents/m, tests/mclass.m):
Save with correct indentation for blank lines.
Add tests with function ... end on the same line.
2021-03-04 15:28:46 -05:00
Eric Ludlam 44e19af23d matlab.el:
(matlab-cursor-on-valid-block-start):
Replaced previous fix by only looking at the previous end
and verifying it is indented by the standard level.
This (of course) assumes that the whole file is indented correctly.
2021-03-01 19:09:38 -05:00
Eric Ludlam 9872d929ec matlab.el:
Speed up checking for valid class block keywords.
(matlab-find-prev-code-line): New.
Looks for a previous line of code and navs to the beginning of it.
(matlab-cursor-on-valid-block-start):
Stop navigating for full syntactic block check, just look at
prev command and verify it belongs to a class and assume it is correct.
(matlab-previous-line-belongs-to-classdef-p):
New.  Verify previous thing is a class based keyword.
(matlab-calculate-indentation-1):
When indenting `end' ask matlab-backward-sexp to not throw errors.
2021-02-28 12:21:27 -05:00
Eric Ludlam ede79ff02d matlab.el:
Revamp how function...end is handled.
(matlab-functions-have-end): Set default to 'guess.
(matlab-functions-have-end-minor-mode):
Set the lighter to be dynamic.
Set matlab-functions-have-end to the script type, or guess.
(matlab-guess-script-type): New
(matlab-do-functions-have-end-p):
Set directly based on script type.
Only navigate to detect end for functions.
(matlab-toggle-functions-have-end-minor-mode):
No not set `matlab-functions-have-end'.  This is done in the minor mode call.
(matlab-find-code-line): New utility used by
`matlab-guess-script-type'.
(matlab-defun-regex): Move whitespace outside of first group.
(matlab-indent-line): Prevent move-to-column from
ever getting a negative number.
(matlab-calculate-indentation-1): Replace setting of functions have end
to instead call the minor mode which will do the work.
(matlab-mode-vf-add-ends): Only skip check in fast mode.
(matlab-mode-vf-block-matches-forward):
Re-detect with `matlab-guess-script-type'.
Check script type against existing value of matlab-functions-have-end and
auto update quietly with no questions.
Use script type to minimize when questions are asked when we do check the blocks.
Always use minor-mode to set value of matlab-functions-have-end.
2021-02-28 11:25:58 -05:00
Eric Ludlam e2f684ddc3 tests/blocks.m
Add some more torture tests around methods, events, and argument blocks from John.
2021-02-28 06:34:33 -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 e437a87761 matlab-shell.el:
(matlab-shell-save-and-go): Use 'emacsrun' insteaad of 'run'.
toolbox/emacsrun.m:
New file.  Calls clear on the m file before running it.
Used in matlab-shell-save-and-go.
2021-02-27 13:59:22 -05:00
Eric Ludlam 3fd09f43f5 Separate font-lock keywords that are only for M files, and those that
work fine for files and the shell.
matlab.el:
(matlab*-font-lock-keywords): Use defconst.
(matlab-font-lock-keywords): Rename to:
(matlab-basic-font-lock-keywords): New
and remove lines to:
(matlab-file-basic-font-lock-keywords): New.
(matlab-gaudy-font-lock-keywords): Rename to:
(matlab-file-gaudy-font-lock-keywords): New
and only use keywords for -file- and both.
(matlab-mode): Use new named keywords.

matlab-shell.el:
(matlab*-font-lock-keywords): Use defconst.
Use only keywords from matlab.el meant for both files and shell.
(matlab-shell-object-output-font-lock-keywords): New
2021-02-27 11:41:29 -05:00
Eric Ludlam 6dbdf778f9 matlab.el:
(matlab-function-font-lock-keywords):
Support functions with names that are prepended with set. or get.
which are valid set/get methods.
2021-02-25 21:47:12 -05:00
Eric Ludlam 0c9226c430 matlab.el:
(matlab-mcos-innerblock-regexp, matlab-mcos-regexp):
Tweaks to support changing ...
(matlab-innerblock-syntax-re): Remove fcn from this regexp.
(matlab-cursor-on-valid-block-start): Don't do special
validation for 'function'.
2021-02-25 21:20:58 -05:00
Eric Ludlam d1cf00a95a tests/blocks.m
New file with lots of examples of strange uses of block syntax.
2021-02-25 21:10:48 -05:00
Eric Ludlam c12e9bcc65 matlab.el:
Support some block keywords like 'arguments' to be used as a variable or fnc name.
(matlab-keyword-list): Remove MCOS keywords.
(matlab-keyword-first-on-line-list): New, is MCOS keywords from a bove.
(matlab-font-lock-keywords): Show first-on-line keywords only if first on a line.
(matlab-mcos-innerblock-regexp): New
(matlab-mcos-regexp): Now uses above, but add classdef.
(matlab-block-syntax-re, matlab-innerblock-syntax-re): New
(matlab-block-start-scan-re): New
(matlab-backward-sexp): When block start found, use `-on-valid-block-start' in addition to
'-in-string-or-comment'.
(matlab-forward-sexp): Same check when block start is found.
Also new input 'parentblock' can be used to speed up valid block start check.
Use the new input when recursing.
Use 'matlab-block-start-scan-re' instead of building local regexp.
(matlab-valid-block-start-slow-and-careful): New setting
(matlab-cursor-on-valid-block-start): New.
(matlab-current-syntactic-block): New
(matlab-lattr-block-cont): Make sure blocks found are valid.
(matlab-show-paren-or-block): Make sure blocks found are valid.
Use new block-re fcns for regexp.
2021-02-25 21:10:20 -05:00
John Ciolfi 00e25f897c tlc: new version 1.3, revamped implementation 2021-02-25 09:41:12 -05:00
Uwe Brauer 935c67274b Merge remote-tracking branch 'origin/usage1' into master. 2020-12-04 08:36:18 +01:00
Eric Ludlam 93a7478486 matlab-complete.el:
(matlab-complete-symbol): Check if matlab-shell was loaded before
checking if the shell is active.
2020-11-30 13:59:51 -05:00
Eric Ludlam c22998376b matlab-complete.el:
(matlab-complete-symbol): Renamed to matlab-complete-symbol-local.
(matlab-complete-symbol): Dispatch to either `matlab-complete-symbol-with-shell' or
`matlab-complete-symbol-local'.
2020-11-29 09:15:49 -05:00
Eric Ludlam d9eabbb385 (matlab-font-lock-allstring-comment-match-normal):
Protect against "..." at end of file.
(matlab-is-matlab-file):
Protect against files w/ version nnums and archived subfiles.
2020-11-29 09:14:36 -05:00
Eric Ludlam afe1e636fd matlab.el:
(matlab-is-mcr-file): Remove
(magic-mode-alist): remove MCR specific setting.
2020-08-15 21:10:12 -04:00
Eric Ludlam 77c23560de INSTALL:
Remove guidance for modifying auto-mode-alist - always use matlab-load
Tweak configuration guidance to suggest using customize
Remove ancient font lock stuff.
2020-08-15 21:07:43 -04:00
Eric Ludlam 3402cdebf4 matlab.el:
(matlab-mode-for-new-mfiles): New setting.
(matlab-is-matlab-file): New test for magic-mode-alist.
(matlab-is-mcr-file): New test for MCR files.
(auto-mode-alist -> magic-mode-alist): Use above to
decide if a file is an objective C file.  If not, do MATLAB.
(matlab-mode-leave): When matlab-mode exists, disable mlint mode.
(matlab-mode): Add change-major-mode-hook for `matlab-mode-leave'
(matlab-frame-init, matlab-ltype-block-comm)
(matlab-electric-block-comment, matlab-toggle-read-only)
Spelling fixes.
2020-08-15 21:02:30 -04:00
Eric Ludlam 6bcee3f537 +emacs/set.m:
Use new settings API to change EditorBuiltinEditor and EditorOtherEditor
in newer versions of MATLAB.
2020-08-15 17:51:21 -04:00