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
(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.
(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.
(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 #.
(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.
(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.
(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
(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.
(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.
(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.
(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'.
(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.
(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.
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.
(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.
(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.
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.
(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.
(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.
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.
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.
(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.
(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.
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
(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'.
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.
(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'.
Remove guidance for modifying auto-mode-alist - always use matlab-load
Tweak configuration guidance to suggest using customize
Remove ancient font lock stuff.
(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.