(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.
(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.
(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.
(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.
(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.
(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.
(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.
(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.
(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.
(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.
(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.
(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.
(matlab-re-search-keyword-forward): If bad list found, jump to end of buffer.
matlab-syntax.el:
(matlab--scan-line-for-unterminated-string)
(matlab--scan-line-comment-disable-strings): Minor optimization
computing where to drop character category.
(matlab-end-of-outer-list): Error if going to end of list
leaves pt before starting location.
(matlab-re-search-keyword-forward): No longer error if inside an unterminated list.
Just fail to find the next keyword.
matlab-syntax.el:
(matlab-in-list-p): New
(matlab-beginning-of-outer-list, matlab-end-of-outer-list):
Change from let* to simplify.
(mlf-paren-inner-point): New var.
Renumbered all the other vars.
(matlab-compute-line-context-lvl-1):
Add paren inner point into list.
(matlab-line-close-paren-inner-point): New
matlab.el:
(matlab-calculate-indentation-1):
Update blockendless to use new apis
Update plain code continuations to use new apis
when inside parens.
Delete unneeded comments.
matlab.el:
(matlab-find-prev-line): Replace some code w/ newer apis.
(matlab-ltype-comm-noblock): DELETE
(matlab-ltype-comm): Fix doc.
(matlab-lattr-comm): Delete, it was the same as ltype-comm.
(matlab-ltype-comm-ignore, matlab-ltype-help-comm)
(matlab-debug-block-comm, matlab-ltype-function-definition)
(matlab-ltype-code): DELETE
(matlab-calculate-indentation-1):
Replace middle block origin check w/ new API calls.
Other changes: Replace old fcns with new API calls.
Delete unused comments.
(matlab--scan-block-backward-up-until): New
matlab.el:
(matlab-find-unreachable-code): Delete
(matlab-file-basic-font-lock-keywords): No more unreachable code.
(matlab-forward-sexp): Remove INCLUDEELSE input.
Remove usage from everywhere else.
(matlab-beginning-of-enclosing-defun): DELETE.
(matlab-beginning-of-defun, matlab-end-of-defun):
Use new block scanner for impl.
(matlab-calculate-indentation-1): Use new block scanner
for finding defun.
(matlab-hideshow-*): Deleted - it was never finished.
matlab-semantic.el:
Update to new matlab-forward-sexp inputs.
(matlab-end-of-comment-point): New
(matlab-line-code-p): Fix doc.
(matlab-line-boring-code-p): New
(matlab-line-end-of-code): New defubst
(matlab-line-end-of-code-needs-semicolon-p): New
matlab-shell:
(matlab-read-line-at-point): replace cmd grab with
simpler new version.
(matlab-shell-run-cell): Stop using obsolete input to matlab-end-of-command.
matlab.el:
(matlab-region-face): Get rid of old compatibility code.
(matlab-function-font-lock-keywords): Use new end-of-command fcn.
(matlab-beginning-of-command): Delete old impl, use new only.
(matlab-lattr-implied-continuation)
(matlab-prev-line-cont, matlab-lattr-array-cont)
(matlb-lattr-array-end, matlab-lattr-middle-block-cont)
(matlab-lattr-endless-block-cont, matlab-lattr-local-end): DELETE
(matlab-comment-on-line): Simpler new implementation
(matlab-calculate-indentation-1): Replace some old calls with
new versions.
(matlab-indent-end-before-ret): Replace regex w/ new keyword
handler.
(matlab-semicolon-on-return): Replace impl w/ new semicolon api
(matlab-fill-paragraph): Replace old api calls w/ new.
(matlab-mode-vf-quiesce-buffer): Replace lots of old parsing code
with simple calls from new api.
(describe-line-indent-context): Take inputs, and option to return msg
instead of display it.
matlab.el:
(matlab-vers-on-startup, matlab-highlight-block-match-flag)
(matlab-show-periodic-code-details-flag): Delete
(matlab-frame-init): Remove menu items for things just deleted.
(matlab-mode): Only support paren fcn, no more
`matlab-enable-block-highlighting'.
(matlab-block-highlighter-timer, matlab-enable-block-highlighting)
(matlab-highlight-block-match, matlab-block-highlight-*) : Delete
(matlab-show-line-info): Misc improvements.
(matlab--mk-keyword-node): Include end pt of found node.
(matlab--valid-keyword-node): New
matlab-syntax.el:
(matlab-move-simple-sexp-backward-internal)
(matlab-move-simple-sexp-internal):
Make defsubst.
matlab.el:
(matlab-show-paren-or-block):
Re-write how blocks like if ... end are highlighted to use new utils
in matlab-scan.el.
(matlab--valid-mcos-keyword-point, matlab--valid-arguments-keyword-point):
Require these special keywords to be first on the line.
tests/mclass.m:
Add a bunch of badly named methods.
(matlab--scan-block-forward): When fcns have no end, and a new fcn
block start is found and popped, also go to beginning of found keyword
so next forward-sexp sees it and jumps over next fcn.
matlab.el:
(matlab-backward-sexp, matlab-forward-sexp):
Change chars skipped over @ beginning to better represent
what regular forward/backwar-sexp does.
(matlab-scan-block-start-context): New
matlab.el:
(matlab-lattr-block-cont): Rename to
(matlab-lattr-block-open): New name, return 0 not nil.
(matlab--calc-indent, matlab-show-line-info): Call matlab-next-line-indent w/ new inputs.
(matlab-calculate-indentation-1):
Replace old END indent logic with call to `matlab-scan-block-start-context'
and then stabilize dedent to match block start.
(matlab-next-line-indentation): Better inputs based on what's used.
Delete dead code and commented out code.
tests/continuations.m:
Enabled test that now 'works'.
(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.
Add support for block navigation.
(matlab-on-keyword-p): New
(matlab-kwt-indent, mtlab-kwt-blocks): New regex caches
(matlab-keyword-regex): Update interface to be simpler.
Support more caches for regex.
(matlab-compute-line-context-lvl-1):
Update to use new `matlab-on-keyword-p' feature.
(matlab--buffer-block-tree): New (but not yet used)
(matlab--mk-keyword-node, matlab--known-parent-block): New
(matlab--valid-keyword-point, matlab--valid-arguments-keyword-point): New
(matlab--scan-derive-block-state): New
(matlab--scan-block-forward, matlab--scan-block-forward-up): New
(matlab--scan-block-backward, matlab--scan-block-backward-up): New
(matlab--re-search-keyword-forward, -backward): Moved.
matlab-syntax.el:
(matlab-beginning-of-string-or-comment): Add all-comments optional input.
(matlab-end-of-string-or-comment): Add all-comments optional input.
(matlab-syntax-keyword-as-variable-p): New
(matlab-valid-keyword-syntax): New
(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
(matlab-block-keyword-list): Add more keywords.
(matlab-compute-line-context-lvl-1): improve keyword detection
to handle the new types of keywords that don't start blocks.
Improve end of line detection to distinguish command dual from ellipsis.
(matlab-line-commanddual-p): New
(matlab-scan-previous-line-ellipsis-p): Improve how ellipsis is found
to be more explicit.
(matlab-describe-line-indent-context): Show command dual in output.
matlab.el:
(matlab-lattr-cont): Improve how ellipsis is found to be more
explicit.
indents.el:
Add more keyword styles around to deal with command dual problems.
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.
(matlab-kwt-*): New keyword regex caches.
(matlab-keyword-regex, matlab--keyword-regex): New
Create regex for keywords from the keyword table.
(matlab-re-search-keyword-forward, matlab-re-search-keyword-backward):
New search routines that scan for regex outside of strings, comments, and parens.
(matlab-scan-previous-line-ellipsis-p):
Return position, not the column.
(matlab-scan-beginning-of-command):
Recompute the line cache as we search backward.
(matlab-scan-after-change-fcn) ->> rename to
(matlab-scan-before-change-fcn)
(matlab-scan-setup, matlab-scan-disable): Use rename.
matlab.el:
(matlab-lattr-block-close): We can sometimes find
a function for files with endless functions.
Prevent this from acting like an end.
(matlab-indent-region): Disable line-to-line caching
of lvl2. It isn't stable.
Move refreshing of lvl2 here, but comment out.
(matlab--indent-line): Stop refreshing lvl2 here.
(matlab--change-indentation):
Prevent indentation of less than 0.
(matlab--calc-indent): Accept a debug sym.
(matlab-show-line-info): Use new matlab--calc-indent api.
(matlab--indent-line): refresh the context if the line was indented.
(matlab--change-indentation): Fix bug when diff==0
(matlab--calc-indent): Revamp how we compute stuff before matlab-next-line-indentation.
(matlab-next-line-indentation): Use more of the contexts passed in.
Removed `matlab-with-current-command' use. Replaced with direct call.
This shows we no longer need to narrow the region.
Remove help comment computation - it seemed unused.
(matlab-show-line-info): Update for changed apis.
matlab-scan.el:
(matlab-with-context-line): Fix bug computing pt to move to.
Setup edebug to debug into this macro.
(mlf-previous-line1 & 2): Renamed & new slot.
(mlf-previous-command-beginning): New slot
(matlab-compute-line-context-lvl-2): If avail, store a lvl2 context for
the previous line too.
Transfer the previous command into new lvl2 context.
Add stats logging.
(matlab-refresh-line-context-lvl2): New hook to refresh after an indent.
(matlab-previous-line-lvl2): New accessor that fills in if empty.
(matlab-previous-code-line): Protect against bobp.
(matlab-previous-command-begin): New accessor that fills in if empty.
(make-keyword-table, matlab-scan-stat-reset):
Use matlab-obarray-make compat layer.
(matlab-scan-stats-print):
Use mapatoms instead of obarray-map for compat.
(matlab-compute-line-context-lvl-2): Add cache stats capture.
(matlab-previous-code-line): New fcn.
(matlab-scan-comment-help-p):
first arg can now be lvl1 or 2. If lvl2, use it's cached
lines to compute.
(matlab-mode): Specify indent-region-function.
(matlab-lattr-array-cont): Accept lvl2 input and use it when avail.
(matlab-indent-region): New.
Computes a lvl2 context and maintains it line-to-line.
(matlab-indent-line): Compute a lvl2 context.
Move original contents to matlab--indent-line.
(matlab--indent-line): New per-line indenter.
Takes lvl2 context and passes it through.
(matlab-calculate-indentation): Accept lvl2 context, pass through.
(matlab-calculate-indentation-1): Accept lvl2 context.
Derive lvl1 context from lvl2.
(matlab-next-line-indentation): Accept lvl2 context, and use it.
(matlab-comment-indent): Use renamed matlab--calc-indent.
(matlab-show-line-info): compute lvl2 and use it with above changed apis
matlab-scan.el:
(matlab-line-point, matlab-line-indentation): New
(mlf-* for lvl-2 context): Rename for consistency with what they do.
(matlab-compute-linecontext-lvl-2):
Revampe computing of lvl1 (if not passed in), internal names.
Delete old comment stuff (wasn't used.)
Implement cascading lvl2 maintenance from lvl1-prev, or bobp as nil.
(matlab-line-in-array): New helper.
(matlab-scan-cache-get): Log hits to stats.
(matlab-scan-cache-stats): New var
(matlab-scan-stat-reset): New cmd
(matlab-scan-stat-inc): New
(matlab-scan-stats-print): New
(matlab-compute-line-context): Add lvl2 support.
(mlf-indent): New slot
(mlf-end-comment-pt): Rename to match what it is.
(matlab-compute-line-context-lvl-1): Add mlf-indent to output.
(matlab-with-context-line): Macro to just jump to a context.
(matlab-line-comment-ignore-p): Doc fix.
(matlab-line-end-comment-column): Deal with rename of mlf-end-comment-pt.
(matlab-line-end-of-code): New fcn.
(mlf-level1 & others): New
(matlab-compute-line-context-lvl-2): New
(matlab-describe-line-indent-context): Also capture lvl2.
matlab-scan.el:
(mlf-entity-start, mlf-paren-outer-char, mlf-paren-outer-point):
New const, renumber the others.
(mlf-paren-inner-char, mlf-paren-inner-col):
Renamed fro versions w/out -inner in the name.
(matlab-compute-line-context-lvl-1):
Fill in entity start, and outer char/point.
(matlab-line-block-comment-start): New
(matlab-line-close-paren-inner-col, -char):
Renamed to include -inner
(matlab-line-close-paren-outer-char, -point): New
(matlab-line-comment-help-p): Renamed to
(matlab-scan-comment-help-p): Option PT
now specifies if a point is returned instead of a column.
(matlab-scan-previous-line-ellipsis-p): New
(matlab-scan-beginning-of-command): New
(matlab-describe-line-indent-context): Fixup names, etc.
(matlab-beginning-of-command): In comment skip part,
also look for help comments.
(matlab-next-line-indentation): Replace several -lattr-
type commands with new predicates from matlab-scan.el.
matlab-scan.el:
(matlab-line-regular-comment-p): New
(matlab-calculate-indentation-1):
Replace old -ltype- API calls with new API from matlab-scan.el.
Delete chunks of block comment handlers, replaced with simpler
code using matlab-scan stuff.
matlab-scan.el:
(matlab-compute-line-context-lvl-1):
Rename block comment stype values.
When a keyword is found, only enable iff not in parens.
Trailing comment section, if line starts with a comment,
assume it ends with a comment, and compute key values.
(matlab-line-comment-style, matlab-line-end-comment-column)
(matlab-line-ellipsis-p):
New
(matlab-line-end-p, matlab-line-block-middle-p)
(matlab-line-block-case-p):
New
(matlab-line-close-paren-p, matlab-line-close-paren-char)
(matlab-line-close-paren-col):
New
(matlab-describe-line-indent-context):
Fixup for various changes.