Re: [julia-users] How to change REPL mode on startup?

2016-05-16 Thread lapeyre . math122a
Here is a PR

https://github.com/JuliaLang/julia/pull/16384

Given the discussion around https://github.com/JuliaLang/julia/pull/13545, 
I doubt it will be accepted as is. 


John

On Sunday, May 15, 2016 at 10:31:58 AM UTC+2, Rafael Fourquet wrote:
>
> John, I tried your branch which works as expected, thank you. I found 
> that there has been a PR at 
> https://github.com/JuliaLang/julia/pull/13545 related to REPL hooks, 
> not sure how much this overlaps with your solution. In any case, I 
> hope to see this functionality merged. 
>


Re: [julia-users] How to change REPL mode on startup?

2016-05-15 Thread Rafael Fourquet
John, I tried your branch which works as expected, thank you. I found
that there has been a PR at
https://github.com/JuliaLang/julia/pull/13545 related to REPL hooks,
not sure how much this overlaps with your solution. In any case, I
hope to see this functionality merged.


Re: [julia-users] How to change REPL mode on startup?

2016-04-20 Thread lapeyre . math122a
You can try this branch https://github.com/jlapeyre/julia/tree/gjl/replhooks

In .juliarc.jl, you can include code like this:

if isdefined(Base, :atreplrun)
Base.atreplrun( (repl)->repl.interface.modes[1].prompt = "newprompt>" )
end

to install a hook. Call atreplrun repeatedly to push hooks, all of which 
are run (more or less) just before the loop is entered.

John


On Wednesday, April 20, 2016 at 5:54:22 AM UTC+2, Rafael Fourquet wrote:
>
> > Again, I don't know if there is any demand for adding a general 
> > facility for this. 
>
> If you have in mind to make a PR, I would be a client for such a 
> facility. IIUC, this would e.g. allow me to change automatically the 
> prompt by calling a function from .juliarc.jl ? (which I do manually 
> now with "Base.active_repl.interface.modes[1].prompt = ..."). 
>


Re: [julia-users] How to change REPL mode on startup?

2016-04-20 Thread lapeyre . math122a
Yes, AFAIK it is not possible to modify the REPL in .juliarc.jl because it 
is executed before the REPL runs. A tedious workaround is to use 
.juliarc.jl to create a REPL and then exit() upon completion before the 
usual REPL is started. I hadn't thought about a PR, but I can take a look 
at it.
John
 

On Wednesday, April 20, 2016 at 5:54:22 AM UTC+2, Rafael Fourquet wrote:
>
> > Again, I don't know if there is any demand for adding a general 
> > facility for this. 
>
> If you have in mind to make a PR, I would be a client for such a 
> facility. IIUC, this would e.g. allow me to change automatically the 
> prompt by calling a function from .juliarc.jl ? (which I do manually 
> now with "Base.active_repl.interface.modes[1].prompt = ..."). 
>


Re: [julia-users] How to change REPL mode on startup?

2016-04-19 Thread Rafael Fourquet
> Again, I don't know if there is any demand for adding a general
> facility for this.

If you have in mind to make a PR, I would be a client for such a
facility. IIUC, this would e.g. allow me to change automatically the
prompt by calling a function from .juliarc.jl ? (which I do manually
now with "Base.active_repl.interface.modes[1].prompt = ...").


Re: [julia-users] How to change REPL mode on startup?

2016-04-19 Thread lapeyre . math122a

Thanks. I got it working. I copied much of the code in client.jl. In the 
end I wrote the new mode directly into a copy of REPL.setup_interface.  
There is probably an easier way to get the REPL to start in the new mode 
rather than julia, but this was faster for me.  There were many details, eg 
to get warn and error colors working. For me, it would have been far easier 
to use a hook after the REPL is created, but before it runs. But, I guess 
there is probably not much demand for that.

I also copied four functions, changing only `Base.parse_input_line(line)' 
in each (to support dumb terminals, etc.),  to include a macro to 
post-process the AST.  Again, I don't know if there is any demand for 
adding a general facility for this.

John

On Friday, April 15, 2016 at 6:07:00 PM UTC+2, Keno Fischer wrote:
>
> You can call REPL.setup_inferface yourself and add your own REPL mode. You 
> can also look at 
> https://github.com/JuliaLang/julia/blob/master/base/client.jl to see how 
> the active_repl gets created.
>
> On Fri, Apr 15, 2016 at 9:16 AM,  
> wrote:
>
>> I have a REPL mode for an application: 
>> https://github.com/jlapeyre/SJulia.jl/blob/master/src/sjulia_repl.jl
>>
>> I start julia in a terminal,  load the package with 'using SJulia', and 
>> then press '=' to enter the alternative mode.  This works fine.
>>
>> I would like to do this in one step. e.g.  enter 'sjulia' in a terminal 
>> and then start in the alternative mode. Problems are:
>>
>> 1. I have to execute a julia function to start the REPL mode 'after' the 
>> REPL starts and I see the julia prompt. Otherwise there is no active REPL. 
>> Using .juliarc.jl or julia -e apparently loads and runs code before 
>> starting the REPL.  I would like the alternative REPL mode to be created 
>> without entering anything at the julia prompt.
>>
>> 2. Once I create the alternative REPL, I am still in the standard julia 
>> REPL mode. To switch to the alternative mode, I enter '='. I would like to 
>> enter this mode automatically. There is a function Base.LineEdit.transition 
>> that seems to do this. But, it takes a data structure (of type 
>> Base.LineEdit.MIState' ) as an argument that I don't know how to get at.  I 
>> can probably find it buried somewhere in Base.active_repl, but, I have not 
>> been able to so far.
>>
>> -John
>>
>
>

Re: [julia-users] How to change REPL mode on startup?

2016-04-15 Thread Keno Fischer
You can call REPL.setup_inferface yourself and add your own REPL mode. You
can also look at
https://github.com/JuliaLang/julia/blob/master/base/client.jl to see how
the active_repl gets created.

On Fri, Apr 15, 2016 at 9:16 AM,  wrote:

> I have a REPL mode for an application:
> https://github.com/jlapeyre/SJulia.jl/blob/master/src/sjulia_repl.jl
>
> I start julia in a terminal,  load the package with 'using SJulia', and
> then press '=' to enter the alternative mode.  This works fine.
>
> I would like to do this in one step. e.g.  enter 'sjulia' in a terminal
> and then start in the alternative mode. Problems are:
>
> 1. I have to execute a julia function to start the REPL mode 'after' the
> REPL starts and I see the julia prompt. Otherwise there is no active REPL.
> Using .juliarc.jl or julia -e apparently loads and runs code before
> starting the REPL.  I would like the alternative REPL mode to be created
> without entering anything at the julia prompt.
>
> 2. Once I create the alternative REPL, I am still in the standard julia
> REPL mode. To switch to the alternative mode, I enter '='. I would like to
> enter this mode automatically. There is a function Base.LineEdit.transition
> that seems to do this. But, it takes a data structure (of type
> Base.LineEdit.MIState' ) as an argument that I don't know how to get at.  I
> can probably find it buried somewhere in Base.active_repl, but, I have not
> been able to so far.
>
> -John
>


[julia-users] How to change REPL mode on startup?

2016-04-15 Thread lapeyre . math122a
I have a REPL mode for an application: 
https://github.com/jlapeyre/SJulia.jl/blob/master/src/sjulia_repl.jl

I start julia in a terminal,  load the package with 'using SJulia', and 
then press '=' to enter the alternative mode.  This works fine.

I would like to do this in one step. e.g.  enter 'sjulia' in a terminal and 
then start in the alternative mode. Problems are:

1. I have to execute a julia function to start the REPL mode 'after' the 
REPL starts and I see the julia prompt. Otherwise there is no active REPL. 
Using .juliarc.jl or julia -e apparently loads and runs code before 
starting the REPL.  I would like the alternative REPL mode to be created 
without entering anything at the julia prompt.

2. Once I create the alternative REPL, I am still in the standard julia 
REPL mode. To switch to the alternative mode, I enter '='. I would like to 
enter this mode automatically. There is a function Base.LineEdit.transition 
that seems to do this. But, it takes a data structure (of type 
Base.LineEdit.MIState' ) as an argument that I don't know how to get at.  I 
can probably find it buried somewhere in Base.active_repl, but, I have not 
been able to so far.

-John