Commit graph

13 commits

Author SHA1 Message Date
Eric Ludlam 123e38e4a9 matlab-scan.el:
(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.
2021-03-14 22:11:13 -04:00
Eric Ludlam 50552dab81 matlab-scan.el:
(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.
2021-03-14 19:35:09 -04:00
Eric Ludlam 24059939dd matlab.el:
(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.
2021-03-14 00:21:33 -05:00
Eric Ludlam 3542ef0150 matlab-scan.el:
(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.
2021-03-13 21:00:24 -05:00
Eric Ludlam bd55c5a5ec matlab-scan.el:
(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.
2021-03-13 20:38:32 -05:00
Eric Ludlam 7321ab5c83 matlab.el:
(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
2021-03-13 19:46:05 -05:00
Eric Ludlam dc0bafae3a matlab-scan.el:
(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.
2021-03-13 13:17:15 -05:00
Eric Ludlam 7d5a73fb49 matlab-scan.el:
(matlab-block-keyword-list): Add elseif.
(matlab-compute-line-context): Change how cache is called.
(mlf-indent renamed to mlf-point):
(matlab-compute-line-context-lvl-1):
Use above renamed.
(matlab-line-code-p): New predicate.
(matlab-scan-previous-line-ellipsis-p): Fix bug, return column instead.
(matlab-scan-cache-max): New
(matlab-scan-cache-get, matlab-scan-cache-put):
Implement.
2021-03-12 22:12:24 -05:00
Eric Ludlam 71fe525308 matlab-scan.el:
(matlab-describe-line-indent-context):
Improve output by using new slots in lvl1 scan data.
2021-03-12 20:06:00 -05:00
Eric Ludlam 52775e4af3 matlab.el:
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.
2021-03-12 08:00:34 -05:00
Eric Ludlam 06c26b19e7 matlab.el:
(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
2021-03-10 22:15:01 -05:00
Eric Ludlam 0fb21cfebf matlab.el:
(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.
2021-03-10 21:37:51 -05:00
Eric Ludlam a948c123fe matlab-scan.el:
New algorithms for scanning MATLAB files for context.
2021-03-10 19:57:46 -05:00