Julia: REPL: make shell mode sticky?

Created on 30 Mar 2014  Â·  29Comments  Â·  Source: JuliaLang/julia

It's pretty common to type several shell commands in a row. It might be a better workflow if shell mode where sticky and required hitting escape or backspace to exit back to normal repl mode. The same could be done for help mode, but it's unclear to me that you actually want to enter multiple help queries in a row.

REPL speculative

Most helpful comment

Vote for stick shell mode and help mode. I think this will make them consistent to current pkg mode.

All 29 comments

I don't think this is necessary.

Just as a comment, codewise this is almost trivial, the only question is what you want to do.

EDIT: Here's the patch if you want to try out how it feels:

diff --git a/base/REPL.jl b/base/REPL.jl
index 257f346..4699883 100644
--- a/base/REPL.jl
+++ b/base/REPL.jl
@@ -390,7 +390,7 @@ function respond(f,d,main,req,rep)
         end
         println(d.repl.t)
         reset_state(s)
-        transition(s,main)
+        #transition(s,main)
     end
 end

This will probably cause trouble for users that did not intend to type ;.

We could make it opt in, controlled by a global variable. I would very much like this.

I would opt in to that for both shell-mode and help-mode. Entering multiple help() queries in a row is all too normal for this mortal. :)

+1 for sticky shell and help modes. I often want to do many of these things in a row. If the prompt changed to something like help> and shell> I would instinctively type Ctrl+D or Esc to exit. I think these modes should be entered explicitly somehow so it is not confusing.

-1 for sticky modes by default (it is confusing for new users, and does not fit my typical usage).
+1 for ctrl-d and esc to get back from help> and shell>

+1 for explicit sticky shell> and help> mode, ctrl-d sounds natural.

You could also exit shell> and help> with more than 2 newlines in a row.

I think just hitting enter should probably exit an inner mode. That would be obvious, easy to type and keep the unwary from becoming trapped.

I like the idea of sticky shell and help mode. However, I would suggest the Esc key to get out of the mode.

That is the thing that feels the most natural to me. If I am in a dialog box on Windows, and want to get out, I just hit Esc. Similarly, typing ; for shell or h for help, doing my business there in however many lines, and then hitting Esc seems completely natural to me.

It actually took me a little while to figure out that Backspace was the way to get out of the single line help or shell mode if I found myself there unwantingly.

Don't Mode Me In

+1 for LaTeX-style
+1 for sticky not yo be default
+1 for or to exit
-1 for reimplementing emacs in the REPL with femtolisp :)
On Apr 1, 2014 5:20 AM, "Jacques Rioux" [email protected] wrote:

I like the idea of sticky shell and help mode. However, I would suggest
the Esc key to get out of the mode.

That is the thing that feels the most natural to me. If I am in a dialog
box on Windows, and want to get out, I just hit Esc. Similarly, typing ;
for shell or h for help, doing my business there in however many lines, and
then hitting Esc seems completely natural to me.

It actually took me a little while to figure out that Backspace was the
way to get out of the single line help or shell mode if I found myself
there unwantingly.

Reply to this email directly or view it on GitHubhttps://github.com/JuliaLang/julia/issues/6320#issuecomment-39198593
.

Oops. The LaTeX comment belongs in the tab sub thread. Sorry!
On Apr 1, 2014 5:42 AM, "Carlos Mundi" [email protected] wrote:

+1 for LaTeX-style
+1 for sticky not yo be default
+1 for or to exit
-1 for reimplementing emacs in the REPL with femtolisp :)
On Apr 1, 2014 5:20 AM, "Jacques Rioux" [email protected] wrote:

I like the idea of sticky shell and help mode. However, I would suggest
the Esc key to get out of the mode.

That is the thing that feels the most natural to me. If I am in a dialog
box on Windows, and want to get out, I just hit Esc. Similarly, typing ;
for shell or h for help, doing my business there in however many lines, and
then hitting Esc seems completely natural to me.

It actually took me a little while to figure out that Backspace was the
way to get out of the single line help or shell mode if I found myself
there unwantingly.

Reply to this email directly or view it on GitHubhttps://github.com/JuliaLang/julia/issues/6320#issuecomment-39198593
.

One option is, that in addition to the current behaviour
;``Return
or
?``Return
go into sticky mode and
Return
on an empty line exits the inner mode

+1 for not making sticky mode the default
+1 for enter on a blankline taking you out of sticky mode
-1 for ESC, which isn't used very much on OS X to exit things

Well, binding esc as well as blank enter can't hurt, can it?

That's true.

Is there a way to globally turn on sticky mode? Let's just get that and close this.

Yeah, I'd still like this. @Keno?

Yes, I've come around it having it be sticky. I can submit a pull request later.

Hah, I noticed that in your presentation :-)

ESC is used in vi keybindings to exit insert mode, so it will be super annoying for vi veterans.

I would really like to have at least sticky shell mode by default. Both sticky shell and help mode by default have been part of my daily workflow for some time now. IMO sticky help mode is less useful.

Either way there should be an easy way for users to opt in. Currently I use this in my ~/.juliarc.jl:

# Create sticky REPL functions for shell and help modes
const REPL_MODES_METADATA = @compat Dict(
    :shell => 2,
    :help => 3
)

for (repl_mode, mode_number) in REPL_MODES_METADATA
    sticky_mode = @compat Symbol(:sticky_, repl_mode, :_mode)
    @eval function $(sticky_mode)(enable::Bool = true)
        Base.active_repl.interface.modes[$mode_number].sticky = enable
    end
end
function setup()
    @async while true
        if isdefined(Base,:active_repl)    # breaks after this is run!
            greedy_banner()
            @sync begin
                @async sticky_shell_mode()
                @async sticky_help_mode()

Vote for stick shell mode and help mode. I think this will make them consistent to current pkg mode.

Leaving shell mode via blank lines doesn’t sound like a good idea, since this would disable pasting code blocks with empty lines.

Sticky by default would be really nice, how often do you need to exactly type in one command? I think mostly you will enter a few in a row. How often do you first have to change to a sub/parent directory and invoke again, for example? Or git status, git diff, git add …, git commit…

Also it would be really nice to directly get into the (sticky) shell mode by for example invoking julia --shell[mode] or similar!

We can and do detect when code is being pasted and handle it differently, so this could be another case where we do that.

FYI. ipython treat multi-line pasted code as a whole block and will not evaluate line by line, which I personally think is quite convenient. You won't be annoyed by un-necessary results in the middle.

I like to get each evaluation into the REPL history.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TotalVerb picture TotalVerb  Â·  3Comments

yurivish picture yurivish  Â·  3Comments

helgee picture helgee  Â·  3Comments

tkoolen picture tkoolen  Â·  3Comments

felixrehren picture felixrehren  Â·  3Comments