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

REPL: change ^U to delete left part of the line #24948

Merged
merged 2 commits into from
Dec 9, 2017
Merged

Conversation

rfourquet
Copy link
Member

In all REPLs I know, ^U is bound to deleting the lines from point leftwards to the begining of line, so I propose to do just this in the Julia one. To clear the input area (which was bound to ^U), I would think of ^C, which is what IPython does, but it's bound to the "julia debugger" currently, which does seem to be enabled only on windows... does anyone use it, and can we reclaim this binding for clearing the input area?

@rfourquet rfourquet added the REPL Julia's REPL (Read Eval Print Loop) label Dec 6, 2017
@StefanKarpinski
Copy link
Member

+1 to keeping our bindings as standard as possible.

@rfourquet
Copy link
Member Author

I figured out (it was not difficult!) that ^C can clear the input area if it's not empty, and otherwise try to call the debugger (someone using it?). For non-julia modes, does the same (clear the area) and transiton back to julia-mode if the input area is empty. Seems sane to me, good to go?

PS: I also removed the printing of "^C\n\n" which I find non-useful... I will re-add back if requested.

@KristofferC
Copy link
Member

I rather have the ^C being printed.

@rfourquet
Copy link
Member Author

I rather have the ^C being printed.

OK no problem. By curiosity, is it to have visual feedback that Julia understood the message (but couldn't do much about it)? or by consistency with some other shells? Would having the prompt "beeping" be a fine replacement to printing "^C\n" for you?

@rfourquet
Copy link
Member Author

For motivating having a binding for clearing the input area: in shells with readline, you can delete the input line with the combo ^k^u, which is good enough, but with multiline input like in Julia this doesn't work anymore.

@rfourquet
Copy link
Member Author

@KristofferC would you be fine with the REPL "beeping" (the small blink like when pressing backspace when it's not possible) instead of printint ^C ?

@KristofferC
Copy link
Member

I like having it printed (like in the terminal).

@rfourquet rfourquet changed the title [RFC] REPL: change ^U to delete left part of the line REPL: change ^U to delete left part of the line Dec 9, 2017
@rfourquet rfourquet merged commit 8a6a18d into master Dec 9, 2017
@rfourquet rfourquet deleted the rf/repl/ctrl-u branch December 9, 2017 15:15
@fredrikekre
Copy link
Member

How do I disable this?

@KristofferC
Copy link
Member

Can we revert the change to ^C? I like to see what the previous thing I wrote was even if I ^C:ed it and it is also convenient to exit REPL modes from an already started line.

There is also the following weird behavior:

  • Start a REPL
  • Press up, remove the line with ^C, press up, remove with ^C and do this a couple of times.
  • Now press ^C on a blank line.
  • Press up to go through history, this will just go through all the empty lines that got removed from ^C.

@rfourquet
Copy link
Member Author

There is also the following weird behavior:

This is no different than what we had before, except you would use ^-U to clear the lines instead of ^C. I'm not saying it's nice though (we could skip empty lines for example).

Can we revert the change to ^C

What would you propose instead as default key for clearing the input area?

I like to see what the previous thing I wrote was even if I ^C:ed

You could add to your keymap the previous code, although it would be nicer to have it put into an easier function to call. But it's a bit trickier to change the ^C binding which controls getting back to the main julia mode (in REPL.jl); I guess it could be possible to change that from .juliarc.jl by overwriting the mode_keymap function. Definitely more customization convenience is needed!

it is also convenient to exit REPL modes from an already started line.

Are you bothered by having to press ^C twice or to not be able to not delete the started line (your previous point) ? As for reverting, I'm reluctant as it's not clear that you preference is objectively more ergonomic, so I see what IPython does as a sane choice (even if it was apparently not true concerning confirm_exit for many people 😛 ).

How do I disable this?

For ^C, see above, for ^U you can put "^u" => (s, o...) -> Base.LineEdit.edit_clear(s), in your keymap.

@KristofferC
Copy link
Member

What would you propose instead as default key for clearing the input area?

Pressing ^C gave me a fresh prompt, I could see the previous one and I could see that I pressed ^C to abort it. Which is how the shell does (except it doesn't show the ^C). So ^C already worked fine for me for this except the advantages previously listed are now removed.

As for reverting, I'm reluctant as it's not clear that you preference is objectively more ergonomic, so I see what IPython does as a sane choice (even if it was apparently not true concerning confirm_exit for many people

Yeah, forcing people to press twice to do something they previously needed to press once tend to make them annoyed. I don't think copying functionality from IPython just because it is IPython is a good idea.

@rfourquet
Copy link
Member Author

forcing people to press twice to do something they previously needed to press once tend to make them annoyed

Genuinely sorry to contribute to make you annoyed. In this case, it was for getting a more standard binding for ^U, ie. delete from begining of line till the point. I explained why it's useful to have a specific binding to clear the input area, unlike in the shell where ^u^k is a decently short combo. I think it's more necessary to have a binding for clearing the input area, than for cancelling the current input and having it kept in the history (if you don't need to keep it in history/keep seing it above the current line, the current ^C does the job). Obviously you disagree, but we lack more data to choose the default. Then, I think, unlike you again, that following IPython with its many years of maturity is a decent choice.

@KristofferC
Copy link
Member

KristofferC commented Dec 13, 2017

Genuinely sorry to contribute to make you annoyed.

Any change in a UI will leave someone annoyed so no need to apologize :)

Then, I think, unlike you again, that following IPython with its many years of maturity is a decent choice

Well, I would counter that the Julia REPL also has quite a few years of maturity and is in addition a much better REPL than IPython. Also, a large number (thousands) of users muscle memory is also to take into account. Sure, sometimes one has to change UI but then it should be significantly better because it breaks patterns that has been grained into the brain over years of usage and that will be a source of annoyance / awkwardness until you relearn, which might take quite a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants