Skip to content

Matlab syntax and Comment blocks for Matlab and Julia #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

JurajLieskovsky
Copy link

Matlab syntax -
Expands all blocks that can be terminated with "end"
Matches also "function" to "end" for compatibility with octave
Uses array matching from Julia
Keeps matching for "import" in comparison to Julia as does not have the others (haven't used it personally but according to documentation should work correctly)

Comment blocks -
Expands comment blocks for both Matlab and Julia

Fake blocks (Julia and Matlab) -
"fake blocks" which match around code you want to send all at once (speeds up debugging by the means of interpreting line by line).

Deficiencies -
matches Matlab comment blocks even if there is more text after %{ even though I added "\s*$" (r"\s*%{\s*$", thiscmd). Maybe .re library differs from the regex checking tool I was using.

Feature suggestions/plans -
Expanding blocks around array when sending it while on it's last line:
A = [ 1 2
4 3 ]; ["enter"]
Sending only #==# for Julie and %{%} of matlab comment blocks option (de-cluttering your console write-out )

Really loving the package, hope you will find some of the features worth adding.

when running through a file using "ctrl+enter" don't send empty lines.

In essence ignores "cmd" of zero length and also doesn't send "code" of zero length.
Matlab syntax -
 Expands all blocks that can be terminated with "end"
 Matches also "function" to "end" for compatibility with octave
 Uses array matching from Julia
 Keeps matching for "import" in comparison to Julia as does not have the others (haven't used it personally but according to documentation should work correctly)

Comment blocks -
 Expands comment blocks for both Matlab and Julia

Fake blocks (Julia and Matlab) -
 "fake blocks" which match around code you want to send all at once (speeds up debugging ).

Deficiencies -
 matches Matlab comment blocks even if there is more text after %{ even though I added "\s*$" (r"\s*%{\s*$", thiscmd). Maybe .re library differs from the regex checking tool I was using.

Feature suggestions/plans -
 Expanding blocks around array when sending it while on it's last line:
 A = [ 1 2
       4 3 ]; ["enter"]
 Sending only #==# for Julie and %{%} of matlab comment blocks option (de-cluttering your console write-out )

Update getter.py
@randy3k
Copy link
Owner

randy3k commented Nov 30, 2020

Thanks for the contribution, I will take a closer look tonight.

@randy3k
Copy link
Owner

randy3k commented Dec 1, 2020

Could you give an example of backward_sq_bracket_expand?

Edit: oh, there was an example above.

s = sublime.Region(s.begin(), view.line(endline.end()).end())

elif re.match(r".*].*$", thiscmd) and not re.match(r".*\[.*$", thiscmd):
s = self.backward_sq_bracket_expand(s, pattern=r"[\[](?=\s*)")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not very accurate. Imagine we have a string s = "]".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sry didn't realise it would be updating the pull as I make changes to my repository. The square bracket is a work in progress from today.

What is the correct way to do these pull requests? Creating a separate branch for each pull request?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. It is usually a better idea to create a new branch for pull requests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But at least in matlab there are no other uses for square brackets than array definitions so solving the issue you raised should be enough.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I argue that we shouldn’t allow this though. The code is not readable with that style and you should first run a code formatter.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's actually how I format my matrices most of the time.

I personally want the result to be a live matlab interpreter where I can send commands as I write the file. But I will be happy to keep it in my fork with more brute force algorithms, leaving your elegant code as is.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants