Skip to content
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

Custom REPL #175

Open
jonniedie opened this issue Sep 15, 2020 · 5 comments
Open

Custom REPL #175

jonniedie opened this issue Sep 15, 2020 · 5 comments

Comments

@jonniedie
Copy link

It would be cool to have a custom REPL mode. For example:

julia> using MATLAB, ReplMaker

julia> matlab_parse(str) = Meta.parse("mat\"$str\"")
matlab_parse (generic function with 1 method)

julia> initrepl(matlab_parse;
       prompt_text = ">> ",
       start_key = ">>",
       mode_name = "MATLAB-Mode",
       )
REPL mode MATLAB-Mode initialized. Press >> to enter and backspace to exit.
"Prompt(\">> \",...)"

>> $a = rand(5)

julia> b = log.(a)
5×5 Array{Float64,2}:
 -1.21512   -1.33757    -0.716193   -0.603662  -0.386935
 -1.14326   -0.221876   -0.547273   -0.651745  -0.927566
 -0.857629  -3.53289    -1.4385     -1.46277   -1.0012
 -0.677553  -0.0738036  -0.779034   -0.715602  -0.0120908
 -2.45905   -0.314258   -0.0376099  -0.471509  -3.27706

>> figure; plot($b)
@musm
Copy link
Collaborator

musm commented Sep 15, 2020

Agreed

@jonniedie
Copy link
Author

If you're open to a PR with the above, I wouldn't mind making one.

@musm
Copy link
Collaborator

musm commented Sep 15, 2020

Yeah sure. I was playing around with it, it's not bad. Wondering if matlabparse(x) = MATLAB.eval_string(x) so that output is printed, but this would disable printing output, which I think we should have.

@jonniedie
Copy link
Author

Oh nice! That's a good idea. Is there a way to still interpolate Julia variables into that, though? I noticed this didn't work:

julia> a = 10
10

>> rand($a)
Error: Invalid text character. Check for unsupported symbol, invisible character, or pasting of non-ASCII characters.

@musm
Copy link
Collaborator

musm commented Sep 15, 2020

Yeah interpolation is not supported by eval_string

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

No branches or pull requests

2 participants