Commit Graph

30 Commits

Author SHA1 Message Date
Eric Ludlam a5e88cda8e Provide a fix for transpose syntax problem
* matlab-syntax.el (matlab--transpose-syntax): Apply patch provided by Eric Ludlam to fix a transpose syntax problem
2022-04-12 11:11:12 +02:00
Eric Ludlam 66496f07a1 matlab.el:
(matlab-mode) Change default value for `add-log-current-defun-function'
to be `matlab-add-log-current-defun'.
(matlab-current-cell): New
(matlab-add-log-current-defun): New.  Use `matlab-current-defun' or above.

matlab-syntax.el:
(matlab-syntax-setup): Remove extra setting of page-delimiter.
2021-06-20 08:41:36 -04:00
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 af5f6c156d matlab-syntax.el:
(matlab-syntax-commanddual-functions): add 'axis' command.
2021-03-26 18:45:23 -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 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 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 c0d5cce467 matlab-syntax.el:
(matlab-end-of-string-or-comment, matlab-block-comment-bounds):
If the 'end of thing' ends up before the starting point,
throw an error  about the syntax in the buffer being messed up.
2021-03-22 09:47:37 -04:00
Eric Ludlam d7e158f2cc matlab-scan.el:
(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.
2021-03-22 08:29:15 -04:00
Eric Ludlam 609e2f3123 matlab-scan.el:
(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.
2021-03-21 07:17:27 -04:00
Eric Ludlam 400bafe092 matlab-scan.el:
(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.
2021-03-20 13:48:52 -04:00
Eric Ludlam ef7894cea5 matlab-syntax.el:
(matlab--scan-line-for-unterminated-string): When comment found,
disable all quote chars in the comment.
(matlab--scan-line-comment-disable-strings):
Find all syntax " chars and disable as whitespace.

tests/indents.m:
Add tests with ' in comments that impact indent.
2021-03-20 12:11:39 -04:00
Eric Ludlam ec7421cb58 matlab-scan.el:
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
2021-03-19 20:02:58 -04:00
Eric Ludlam e0a7d52385 matlab-scan.el:
(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
2021-03-18 21:48:16 -04:00
Eric Ludlam 3730fb360e matlab-syntax.el:
(matlab-syntax-support-command-dual): New way to control
handling command dual syntax in the syntax table.
(matlab--syntax-propertize): Obey above config by
skipping command dual scanning if nil.

tests/stringtest.m:
Add local variables to enable matlab-syntax-support-command-dual for
this file
2021-03-16 19:09:58 -04:00
Eric Ludlam 9d41e46c98 matlab-scan.el:
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.
2021-03-15 21:52:54 -04:00
Eric Ludlam 99d4f7e625 matlab-syntax.el:
(matlab-cursor-in-string-or-comment)
(matlab-cursor-in-comment matlab-cursor-in-string)
(matlab-beginning-of-string-or-comment):
Convert to a single line impl.
Convert to defsubst.
(matlab-end-of-string-or-comment)
(matlab-beginning-of-outer-list)
(matlab-end-of-outer-list): New
2021-03-14 22:09:41 -04:00
Eric Ludlam 3f239aaefb matlab-syntax.el:
(matlab--put-char-category): If at end of buffer, don't
put the text property there.
2021-03-13 10:45:54 -05:00
Eric Ludlam 023bbcf9f0 matlab-syntax.el:
(matlab--scan-line-bad-blockcomment)
(matlab--scan-line-for-ellipsis):
Remove narrowing to region and use search bound instead.
This should be faster.
(matlab--font-lock-syntactic-face):
Quote in all the faces to avoid compiler warning.
2021-03-12 20:07:33 -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 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 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 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 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