-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add option to run without opening the MATLAB editor #74
Comments
This feature would be awesome! Then I could integrate it in my CI pipeline. |
The only problem is that I am using the smart indent feature provided by the undocumented API of the MATLAB Editor. I don't know if there was a way to use the underlying implementation without opening the Editor physically. Personally I did not find one which does not mean that there isn't any (on other issues others helped me out on some undocumentes magic from Mathworks ... :) ). Other possibility to re-implement the smart indent functionality and drop the usage of the one provided by the editor. |
This would help a lot in making this nice toolbox Octave-compatible, which would be great for people that cannot (or doesn't want) to pay a Matlab license. But I understand it won't be easy and fast to implement. |
Not sure how MBeautifier works today, but it sounds like this feature would essentially require a scanner/parser that can tokenize the code and create a full blown AST. Certainly no small task. |
Played around a bit just for fun and ended up with the following script featuring a poor man's tokenizer:
The script assumes that there is a file called At least simple scripts can processed correctly. Naturally, different keywords are missing and it needs thorough testing but maybe we can come up with something. |
At the risk of spamming in every ticket here; writing a fully working MATLAB lexer is an insane activity. Please refer to this for my analysis on this, if you want to know more: https://github.com/florianschanda/miss_hit/blob/master/LEXING_ISSUES.md |
Is it possible to support it by https://pre-commit.com/? It can be integrated to CI/CD of https://pre-commit.ci/. Currently pre-commit doesn't support octave/matlab directly. |
@Freed-Wu there is MISS_HIT integration into pre-commit as described here https://florianschanda.github.io/miss_hit/configuration.html |
I use this as part of a pre-commit git hook and also sometimes in large batches of files, so it would be nice to have the option of passing in a filename and have the formatter run without opening the editor for performance reasons. A couple of possibilities for the calling syntax:
An optional parameter:
MBeautify.formatFile('someFile.m', 'someFile.m', 'UseEditor', false);
An optional positional argument:
MBeautify.formatFile('someFile.m', 'someFile.m', '--no-editor');
A new method:
MBeautify.formatFileSilently('someFile.m', 'someFile.m');
The text was updated successfully, but these errors were encountered: