Commit graph

679 commits

Author SHA1 Message Date
Jai Flack
e663e4d645 Update for new emacs 2023-09-17 14:08:07 +10:00
Uwe Brauer
f66183a5fe Add GPLvs3+ header to all files in tests directory 2023-07-25 18:44:32 +02:00
Uwe Brauer
803f9d3d8e Add file COPYING, containing GPL3v+ 2023-07-14 09:47:10 +02:00
Uwe Brauer
9c03ebf876 Update to GPL3+ (see the ChangeLog file for details, files in test directory left out)
* cedet-matlab.el: update to GPL3+

* company-matlab-shell.el: ditto

* company-matlab-shell.el: ditto

* dl_emacs_support.m: ditto

* linemark.el: ditto

* matlab-publish.el: ditto

* semanticdb-matlab.el: ditto

* semantic-matlab.el: Ditto

* matlab.el: ditto

* mlint.el: Ditto
2023-07-12 18:55:41 +02:00
John Ciolfi
3048e9fdf4 fix matlab-shell dbstack first entry hyperlink
Given:
    function foo()
        bar()
    end

    function bar()
        goo()
    end

    function goo()
        keyboard
    end
In matlab-shell, the first stack entry is now hyperlinked:
    >> foo
    K>>  dbstack
    > In foo>goo (line 10)
    In foo>bar (line 6)
    In foo (line 2)
    K>>

Also fixed a couple typos.
2023-04-26 18:16:49 -04:00
John Ciolfi
ec53b38dde remove compile warning related to electric-pair-mode handling
Prior commit to support electric-pair-mode is good, but had warnings when byte-compiling matlab.el.
This commit removes that warning by adding (eval-when-compile (require 'elec-pair)).
2023-04-25 14:31:57 -04:00
Peter Mao
ba655a6e13 Apply patch provided by Peter Mao
* matlab.el (matlab-mode): Apply patch provided by Peter Mao <peter.mao@gmail.com>

--HG--
branch : master
2023-04-24 14:48:55 +02:00
John Ciolfi
b7007223bd matlab and org mode example 2023-04-10 16:05:31 -04:00
John Ciolfi
bda900fd75 matlab.el: replace TAB characters with spaces, add local variable indent-tabs-mode: nil
Now matlab.el whitespace is "clean", meaning that we only use spaces to indent and there's no
trailing whitespace.
2023-04-08 08:10:58 -04:00
John Ciolfi
e8f566af55 matlab: fix org-mode export, fix hang in matlab-mode, indent, spell check
In matlab-last-script-type-guess, handle case of exporting an org-mode '#+begin_src matlab' code
block.  In this case org-mode will create a temporary buffer in matlab-mode, which means
matlab-last-script-type-guess will see an empty buffer, then org-mode will insert the content. To
ensure keywords such as enumeration are syntactically recognized, we set the type to 'class which
covers all matlab language keywords. This works for both classdef's and non-classdef's.

This commit also fixes a hang in matlab-mode (see fontlockhang branch)

Also indented matlab.el and fixed typos
2023-04-08 08:00:14 -04:00
John Ciolfi
4cf540990f mlint: update mlint-platform for mac 2023-01-20 14:38:46 -05:00
Eric Ludlam
e0d127935c Delete (kill-all-local-variables) in the matlab-mode function.
* matlab.el (matlab-mode): Apply patch provided my Eric Ludlam:
delete the line  (kill-all-local-variables) in the matlab-mode function.
2022-10-08 18:23:08 +02:00
Uwe Brauer
5069e3ca00 Add README and matlab-load file (MELPA seems to need that file)
* matlab-load.el (matlab-mode): Add the load file to the
repository, for the MELPA archive.
2022-04-12 11:13:00 +02:00
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
John Ciolfi
45febb409c Fix conflict between matlab-shell debugging and C++ (or other language) debugging.
Fix conflict between matlab-shell debugging and C++ (or other language) debugging.
- matlab-shell debugging previously leveraged gud.el for debugging of *.m files.
- C++ debugging also leverages gud.el for debugging.
- Only one instance of a gud.el debugger can be active. If you run two, say
  *.m debugging and C++ debugging. Then you get odd errors such as the
  ebbreak not being recognized by gdb.
To fix these issue, I copied gud.el and made a new namespace "mlgud". I also
removed a lot of unused code from mlgud.el, though there's still more that can
be removed. Now one can debug *.m files and *.cpp files in one Emacs session.
2022-03-11 14:55:04 -05:00
Uwe Brauer
c945bf5025 Correct a silly typo in company-matlab-shell.el
* company-matlab-shell.el: 677 correct a silly typo: Auctex should be Matlab
2021-11-22 09:33:48 +01:00
Uwe Brauer
c25894b912 Apply patch provided by Karthik Chikmagalur (matlab-shell)
* matlab-shell.el (matlab-shell-region->script): 676 apply patch provided by  Karthik Chikmagalur <karthikchikmagalur@gmail.com>: Copy all local functions to script.
2021-07-26 10:58:42 +02:00
Uwe Brauer
3fbc97b3f2 Merge the hairycode branch into master. Start testing. 2021-07-16 14:47:29 +02:00
Eric Ludlam
4facc02116 matlab.el:
(matlab-function-font-lock-keywords):
Fix bug in last submit so tests pass.
2021-07-11 12:45:08 -04:00
Eric Ludlam
02dd1b50fb Merge branch 'hairyblocks' of ssh://git.code.sf.net/p/matlab-emacs/src into hairyblocks 2021-07-11 12:36:56 -04:00
Eric Ludlam
b7e170ee37 NEWS.org:
Add version 5 news.
2021-07-11 12:36:35 -04:00
Eric Ludlam
aae075a3b0 matlab.el:
(matlab-mode-menu, matlab-mode): Remove reference to `matlab-indent-sexp' which was deleted.
(matlab-function-font-lock-keywords, matlab-calculate-indentation):
Improve regex for detecting end of 1st argument for functions that treat the
first argument special.
2021-07-11 12:36:17 -04: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
Uwe Brauer
c5824936cc Apply patch provided by Julien Claisse (trump support)
* toolbox/emacsrunregion.m (emacsrunregion):
          Apply a patch provided by Julien Claisse: trump support
2021-05-04 16:39:41 +02:00
Eric Ludlam
7dae6d8514 mlint.el:
(mlint-error-id-fix-alist): Add MSNU as delete-focus auto-fix.
(mlint-lm-delete-focus:: mlint-fix-entry): Also delete horizontal space if at eol.
2021-04-22 15:07:10 -04:00
Eric Ludlam
194f9a9868 mlint.el:
(mlint-error-id-fix-alist):
Add MCSCC for bad constructor name to be auto fixable.
(mlint-lm-function-name::initialize-instance):
Add matcher for MCSCC warnings.
2021-04-17 10:38:22 -04:00
Eric Ludlam
94e3625d5b matlab.el:
(matlab-hg-primitives-list): Fix typo of a command name.
(matlab-comment-on-line): Fix this fcn to do what the doc says.

mlint.el:
(mlint-mark-ok): Separate the 2 cases of existing comment or not and
do each with special code.  Make sure the OK is put in the right
place.
2021-04-15 13:24:51 -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
John Ciolfi
587ad07306 tlc: update tlc-mode to delete trailing whitespace on RET 2021-04-10 09:40:15 -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