Commit graph

650 commits

Author SHA1 Message Date
Eric Ludlam
4611551deb matlab-scan.el:
(matlab--valid-arguments-keyword-point):
If previous code is 'end', make sure it matches a valid arguments block.
(matlab-re-search-keyword-forward,matlab-re-search-keyword-backward):
When checking if in string/comment, don't pass in 'all comments' as t.
Do that only if in a comment.

matlab-syntax.el:
(matlab-beginning-of-string-or-comment):
Make doc accurate.
(matlab-end-of-string-or-comment):
Fix logic for case when not in a comment to only skip all comments if
looking at a comment.  Avoid moving pt if just looking at whitespace.

matlab.el:
(matlab-do-functions-have-end-p):
Improve scanning for end to not do condition-case.
This was hiding an error that was causing incorrect answer.
2021-04-11 15:35:26 -04:00
Eric Ludlam
bda0b63da3 matlab-syntax.el:
(matlab-beginning-of-string-or-comment):
If 'all-comments' is passed in, always skip those comments even if
not in a comment right now.
(matlab-end-of-string-or-comment):
If 'all-comments' is passed in, always skip those comments even if not
in a comment right now.
Make a defun, not defsubst since it is getting pretty big.

matlab.el:
(matlab-mode-menu): Remove navigate menu.  No special navigation anymore.
(matlab-mode): Setup beginning-of-defun-function and end-of-defun-function.
(matlab-beginning-of-defun, matlab-end-of-defun):
Update to have input arg like built-in version.
Be more robust about skipping over comments between defuns.
(matlab-beginning-of-defun-raw): New - from above.
(matlab-skip-over-defun): New.
(matlab-current-defun): Use raw version.
(matlab-show-line-info): Fix bug.
Also print name of current defun.
2021-04-10 13:54:58 -04:00
Eric Ludlam
6c833f4426 matlab-syntax.el:
(matlab-move-simple-sexp-backward-internal,matlab-move-simple-sexp-internal):
Set `forward-sexp-function' to nil so the next call doesn't route to
`matlab-forward-sexp' by accident.

matlab.el:
Disable custom stuff related to navigating sexp, and instead depend on `forward-sexp-function'
to enable built-in Emacs behavior in all cases, not just the special ones we added.

(matlab-mode-map): Remove all bindings that do navigation.
(matlab-mode): Remove comments about custom nav commands.
Set `forward-sexp-function' to `matlab-forward-sexp-function'.
(matlab-forward-sexp-fcn): NEW
(matlab-backward-sexp, matlab-forward-sexp): Remove interactive key.
2021-04-10 07:54:15 -04:00
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
6d28272cfc matlab.el:
(matlab-font-lock-anchor-variable-match): . is ok in arguments variable names.

tests/blocks.m:
Added sample argument block using variable name as struct with . in it.
2021-04-09 17:28:09 -04:00
Eric Ludlam
4d261a86a2 matlab-scan.el:
(matlab--valid-arguments-keyword-point):
Argument keywords are ok after an 'end' as well - assuming the 'end' is
another argument block - but we don't check that part, just hope for the best.

tests/blocks.m:
Add example with two argument blocks in a row.
2021-04-09 17:19:37 -04:00
Eric Ludlam
9f7a03e83f matlab-scan.el:
(matlab-line-declaration-name):
Fix finding name when there are coninuations around the return arguments.
2021-04-04 17:30:06 -04:00
Eric Ludlam
509796c079 matlab.el:
(matlab-calculate-indentation):
Optimize calling `matlab--previous-line-indent-recommendation' only
once in case of checking indentation level less than max indent.
2021-04-02 22:42:32 -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
61b24bec94 matlab.el:
(matlab--previous-line-indent-recommendation):
If scanning backwards finds empty line @ beginning of buffer,
then just return 0.

tests/indents.m:
Add blank first line to exercise above.
2021-04-02 20:55:46 -04:00
Eric Ludlam
c934a0c0f9 matlab.el:
(matlab-indent-past-arg1-functions): Wrap expression
to only be whole-symbols.
(matlab-function-font-lock-keywords): Accomodate change
to above.

tests/indents.el:
Add test that used to indent as if it were a fcn that
indents past arg1, but shouldn't.
2021-04-02 20:43:01 -04:00
Eric Ludlam
9438d95d55 matlab.el:
(matlab-fl-opt-continuation, matlab-fl-opt-whitespace)
(matlab-fl-fcn-key, matlab-fl-return-args)
(matlab-fl-fcn-name, matlab-fl-fcn-args):
New regex parts for building font lock keywords.
(matlab-function-font-lock-keywords):
Revamp using above keyword parts.
Now handles continuations between different parts of
the function declaration.

tests/fontlock.m:
New tests for various function declaration flavors with
and without ellipsis between differentparts.
2021-04-02 20:31:55 -04:00
Eric Ludlam
398667e53f matlab-scan.el:
(matlab-scan-comment-help-p): After finding prev code line,
move to beginning of that command before detecting the declaration.
(matlab-scan-beginning-of-command): Add a code-only
input to skip comment scanning.

tests/continuations.m:
Add tests with continuations in function declarations to better
test new fcn comment scanning.
2021-04-02 20:29:53 -04:00
Eric Ludlam
4e35f8bf85 matlab.el:
(matlab-indent-region, matlab-indent-line):
Remove use of matlab-navigation-syntax.
I don't think we need this anymore - and it messes
up optimzations w/ syntax-ppss anyway.
(matlab-next-line-indentation):
When checking for block-middle or block-case, pass
in the correct lvl1 context for analysis.
Fixes bug w/ indentaion after a middle or case that
has a continuation.

tests/continuations.m:
Add new test cases for elsif and case with continuation.
2021-04-01 21:23:00 -04:00
Eric Ludlam
f4c6a803fb matlab-scan.el:
(matlab-scan-previous-line-ellipsis-p):
Use `parse-partial-sexp' instead of `syntax-ppss' b/c
for ellipsis, we only need to check from bol, and parens
and comments can be ignored.

matlab.el:
(matlab-line-count-open-blocks, matlab-line-count-closed-blocks):
Update to accept 2 lvl1 context for the start and end of the block searches.
Use these to bound the search, and avoid creating more contexts, and avoid
calling `matlab-scan-beginning-of-command'.
(matlab-next-line-indentation):
Be careful about calls that require syntax to propertize the buffer.
Starting with input lvl1, capture lvl1 ctxt for beginning of command
and use that for remaining calls.  This makes it more explicity about
what is being checked where, and faster.
2021-04-01 12:51:58 -04:00
Eric Ludlam
b8343915f9 matlab-scan.el:
(matlab-compute-line-context-lvl-1):
Optimize use of `syntax-ppss'.  See big comment for details on how it works.

matlab.el:
(matlab-functions-have-end-minor-mode):
Re-enable command-line-dual checking in classes.
2021-04-01 09:14:07 -04:00
Eric Ludlam
32aef8ebc1 matlab.el:
(matlab-functions-have-end-minor-mode):
When activating this mode for classes, now disable command-dual support.
Speeds up indenting very large classes.
2021-03-31 20:51:55 -04:00
Eric Ludlam
41f3206733 matlab.el:
(matlab-calculate-indentation):
For continued from previous non-continued line, no arrays:
Include indent recommendation from the previous line to account for
indentation under ctrl blocks.
(matlab-next-line-indentation):
While computing startpt, be sure to move pt to the line that was
passed in.
2021-03-31 13:07:11 -04:00
Eric Ludlam
e6e362a5a4 tests/indents.m, tests/mclass_cont.m:
Change indentation expecatations of some lines to match bug fix.
2021-03-30 22:17:39 -04:00
Eric Ludlam
b01dd6d63d matlab.el:
(matlab-calculate-indentation):
Break continuations into 2 bins:  Those from parens, and those not.
Isolate non-paren version to avoid calling 'beginning-of-command'.
Instead just look at previous line, and decide if we need to do a
continuation indent or not, otherwise just follow the previous line.
2021-03-30 22:14:20 -04:00
Eric Ludlam
3b21236546 matlab-shell.el:
(matlab-shell-font-lock-keywords, matlab-shell-object-output-font-lock-keywords):
Move a few extra things out of base keywords and into next level keywords.
2021-03-30 20:52:15 -04:00
Eric Ludlam
ed4dbaf02e mlint.el:
(mlint-lm-replace-focus::initialize-instance)
(mlint-lm-function-name::initialize-instance)
(mlint-lm-entry-deprecated::initialize-instance):
Quote in the class name when passed to oref-default to silence warning.

semanticdb-matlab.el:
(semanticdb-project-system-databases)
(semanticdb-project-database-matlab::semanticdb-get-database-tables)
Use 'make-instance' to create instances of classes.
2021-03-30 20:37:04 -04:00
Eric Ludlam
9c5e34d633 matlab-shell-gud.el:
(mlg-set-stack, mlg-add-breakpoint):
Use make-instance to create instances of objects.
2021-03-30 12:48:38 -04:00
Eric Ludlam
7082d4f2bf toolbox/emacsrun.m:
Convert input 'args' to 'varargin' so they can be optional.
2021-03-30 11:07:44 -04:00
Eric Ludlam
54b3279762 matlab-shell-gud.el:
(matlab-shell-mode-gud-enable-bindings): Remove call to `matlab-frame-init'
which is obsolete.
2021-03-30 11:07:16 -04:00
Eric Ludlam
7c41d9a151 matlab-scan.el:
(mlf-previous-line*): Deleted, renumber the rest.
(matlab-compute-line-context-lvl2): Stop tracking prev line1/2,
these weren't being used.
(matlab-previous-line, matlb-previous-line-lvl2): These weren't used.
(matlab-line-in-array): Deleted - replaced the few uses.

matlab.el:
(matlab--previous-line-indent-recommendation): Replace
matlab-line-in-array with it's 1 line implementation.
Remove `matlab-previous-line' which could never have a non-nil value.
(matlab-show-line-info): Pass nil into matlab-next-line-indentation
since it will compute as needed, and old fcn always returned nil anyway.
2021-03-28 10:22:40 -04:00
Eric Ludlam
8a133c47b2 matlab.el:
(matlab-mode): Make show-paren-data-function buffer local
before setting it.
2021-03-27 19:59:02 -04:00
Eric Ludlam
8e9dd2e46f matlab-scan.el:
(matlab-line-comment-p, matlab-line-regular-comment-p, matlab-line-boring-code-p):
Fix doc.
(matlab-line-declaration-name): NEW

matlab.el:
(matlab-match-function-re, matlab-match-classdef-re): DELETE
(matlab-mode-vf-functionname, matlab-mode-vf-classname):
Re-write to use `matlab-line-declaration-name' instead of regex.
2021-03-27 14:52:35 -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
2f6958d102 matlab.el:
(matlab-frame-init): Delete as function.
Content is no longer in a fcn since menus supported in terminal mode.
(matlab-mode): Stop calling frame init.
(matlab-mode-vf-block-matches-forward):
Rewrite to use new APIs for searching for keywords and getting
locations of the keywords.
2021-03-27 10:01:56 -04:00
Eric Ludlam
a20a946e20 matlab.el:
(matlab-mode-verify-fix-file):
Re-write to use mapc.
Always call `matlab-mode-vf-guess-functions-have-end'.
(matlab-mode-vf-guess-functions-have-end): NEW
copied from below.
(matlab-mode-vf-block-matches-forward):
Remove code that is now in above fcn.
Replace with small check to auto-select fast mode.
2021-03-27 09:14:44 -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
af5f6c156d matlab-syntax.el:
(matlab-syntax-commanddual-functions): add 'axis' command.
2021-03-26 18:45:23 -04:00
Eric Ludlam
882cbd385f matlab-scan.el:
(matlab--valid-keyword-node): input 'node' is now optional.
(matlab--scan-next-keyword):
Fix typo for 'args input extra filter.
If any old keyword requested, use generic valid keyword filter.
2021-03-26 18:44:47 -04:00
Eric Ludlam
f9df26d3f2 matlab-maint.el:
(matlab-maint-run-tests): Save current buffer w/out asking, as that
is typically what I want.
2021-03-26 18:43:13 -04:00
Eric Ludlam
c039c7369f matlab-syntax.el:
(matlab--scan-line-for-command-dual):
Fix typo in logic to pull goto-char out of and construct.
2021-03-26 15:09:22 -04:00
Eric Ludlam
373023d062 matlab-syntax.el:
(matlab--scan-line-for-command-dual):
Don't do cmd dual checks if inside a list.
2021-03-26 12:57:36 -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
ed9d811014 matlab.el:
(matlab--calc-indent): Stop computing next line indent.
That is done elsewhere.
(matlab--previous-line-indent-recommendation): New, from
matlab--calc-indent old logic.
(matlab-calculate-indentation): DELETED - but renamed
(matlab-calculate-indentation-1): Renamed to old deleted fcn.
Deleted input current-indentation.
Replaced all uses of old input with call to
`matlab--previous-line-indent-recommendation'.  This means many more
cases of indentation don't need to compute their indent from the previous
line.
Also refactored some sections to use cond statement instead of nested if.
Revamped continuations block to not create return inline, but to use tmp
for indent and return data is now more obvious.
2021-03-25 22:43:13 -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
7b49b6f447 matlab-syntax.el:
(matlab-syntax-support-command-dual): Default to t
(matlab-syntax-commanddual-functions): List of functions
commonly used with command line dual.
(matlab--scan-line-for-command-dual): Use above lists
instead of anti-keyword detection.

tests/fontlock.m, tests/indents.m:
Add tests for command dual.

tests/stringtest.m:
Command dual test updated to use 'disp'
2021-03-24 22:08:52 -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
047a4fa0b4 matlab-maint.el:
(matlab-maint-reload-mode): New command.
2021-03-24 21:36:21 -04:00
Eric Ludlam
3df48a0b24 matlab.el:
(matlab-file-class-font-lock-keywords): classdef keywords
work when no space between fn and paren.

tests/fontlock.m:
Add test for above.
2021-03-24 17:24:36 -04:00
Eric Ludlam
859b7fde44 matlab.el:
(matlab-ltype-empty, matlab-ltype-comm): DELETE
(matlab-ltype-continued-comm): Rename to
(matlab-line-continued-comment)
(matlab-lattr-block-open): Rename to
(matlab-line-count-open-blocks)
(matlablattr-block-close): Rename to
(matlab-line-count-closed-blocks)
(matlab-calculate-indentation-1): Use new names.
(matlab-next-line-indentation): Use new names.
(matlab-comment-return): Simplify.
(matlab-comm-from-prev): New
(matlab-electric-comment): Simplify
(matlab-comment): Use new apis.
Simpilfy.
(matlab-set-comm-fill-prefix, matlab-find-convenient-line-break)
(matlab-fill-paragraph, matlab-mode-vf-functionname)
(matlab-mode-vf-classname, matlab-show-line-info)
Use new api

matlab-cgen.el:
(matlab-insert-end-block, matlab-insert-next-case):
Use new api for finding empty lines.

matlab-complete.el:
(matlab-lattr-semantics):
Use new api for finding empty lines.

matlab-shell.el:
(matlab-shell-run-cell):
Use new api for finding comment lines.
2021-03-23 20:29:55 -04:00
Eric Ludlam
2dfa431209 matlab.el:
(matlab-toggle-read-only):
Move to a better spot.
2021-03-23 19:44:39 -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
12ab97f025 matlab.el:
(matlab-*-face): Move all faces into the font lock section of hte code.
2021-03-23 17:32:20 -04:00
Eric Ludlam
2094a595f1 linemark.el:
(linemark-find-file-hook): Wrap call to linemark display
with condition-case to prevent errors from eieio.
2021-03-23 17:10:47 -04:00