Remove the readline shell machinery#9399
Conversation
|
Whoooo ! Will review ! |
|
So before reviewing I'll still ask: It seem like PTShell make it more difficult (impossible) to us this in things like emacs inferior shell. It will likely not be the only one, so should we really get rid of the readline one ?Or leave it as an option ? |
+1 otherwise. |
I'm concerned that if we have two sets of terminal interaction code and are mainly using one, it will bit rot. Maybe we could split it out and have it as a separate package for emacs users to maintain? But the APIs the InteractiveShell subclasses use are not very well defined, so I'm not really keen on that either. |
ping @tacaswell
Fair enough. We can always resurrect the code from git right ? That's what the |
|
I am motivated to look in to this (and suspect that it can be fixed on the emacs side) and if not then on the pt side to not emit some escapes. Emacs chokes in a function that converts ansi escapes into emacs font faces. This is 90% conjecture. |
|
Great, I'm glad someone has the motivation to investigate. We'll put this on hold for the moment then to see if you can work the issue out. If it's not possible, we'll work out what we're going to do. |
|
@tacaswell have you had a chance to look at this? |
|
A bit but not enough to resolve it. On Tue, May 10, 2016, 06:18 Thomas Kluyver notifications@github.com wrote:
|
|
@tacaswell any more updates? I'd like to get this code out before we release 5.0. |
I would be +1 for merging, we can revert if really necessary, but I don't see us reverting PTK for now. |
|
between day-job and mpl 1.5.2/2.0 I have had no time 😞 When is 5.0 slated to be out? attn @jorgenschaefer who might be able to tell me that is is just a minor configuration thing. |
|
I do not use ipython, so no idea about any of this, sorry. Emacs' Though, considering the release cycle, that can take a while. For the curious, the Python code Emacs uses: https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/python.el#L3206-L3254 |
I hear you.
I'd like to have it out for end of June, to have pushed in conad for SciPy.
Thanks for pitching in. Will try to get a few emacs-users to pitch in, will ping people on ML, and twitter. |
|
Does this remove the dependency on gnureadline on Macs? That would be nice :-) |
|
Yep, and the dependency on pyreadline on Windows :-) |
|
@jorgenschaefer The issue is not with calls into ipython, it is with colorizing the string that comes back from ptprompt Which given how badly gh is mangling this copy/paste makes me assume it is an encoding issue. |
|
Looks like a bug in |
|
@tacaswell As a workaround, you can probably use |
|
I think we add the discussion on twitter, and as far as I can remember it's a question of inferior-shell, vs ansi-terminal:
I know there is a reason why you can't use ansi-term, but I'm not sure I remember why. Also as we see on the screenshots, the color does works, it's so extra escape sequences that are broken, so I'm unsure NoColor is a solution. [edit] I have no clue what I am doing above. |
|
The reason I use shell instead of ansi-term is that in what |
Ah, yes I'm starting to remember. Then could elpy be made configurable to use ansi-term ? Or is there a reason not to ? (https://www.masteringemacs.org/article/running-shells-in-emacs-overview) |
|
@takluyver would one option be to "extract" the readline TIS thing into a separate package and "offer it to the community" [Yes I know this solution |
|
It is difficult to interact with ansi-term from Emacs proper. All the REPL modes use comint. (In theory, ipython should check termcap/terminfo capabilities and not send colors or any terminal commands at all – |
|
So technically it's not color, it's the cursor movement sequences and blinking (plus a few other I haven't tracked down yet) , and as this is mostly how prompt_toolkit does it thing, it will likely be super hard to avoid. Looking a bit at it, it should be (relatively) straightforward to export the "old" terminal interactive shell out of there into a separate package. Tell me if I'm wrong but That would (at least) give some fallback for the time being until we figure out a better plan. As I'm unsure about how |
|
It's certainly possible to split out the old TIS as a separate package, but I'm wary of doing that, because:
I don't know what the answer is here, but I'm really not keen on the idea of a separate readline TIS package. There is a very dumb fallback mode used for tests, which just uses Python's |
That untrue for magics, ls, and all the syntax on top of Python. |
|
And most importantly (from my point of view) the gui event-loop integration management. |
|
Have a go with the environment variable |
|
One option that might work for a community maintained package is to clean up jupyter_console 4.x, rename that and push it out for whoever's interested in maintaining it - that way it's built on a clearly defined interface (the messaging protocol), and it can take advantage of the event-loop integration in the kernel. jupyter_console 5.x is also based on prompt_toolkit, but 4.x uses readline. |
|
(we could call it 'jupyter inferior shell', which would be accurate in more ways than one ;-) |
|
Using IPY_TEST_SIMPLE_PROMPT=1 appears to fix things for me. Colors are off from what they were, but I suspect that I can find the right On Thu, May 26, 2016 at 5:37 PM Thomas Kluyver notifications@github.com
|
|
Have you tested with event loop integration? I'd be surprised if that works with IPY_TEST_SIMPLE_PROMPT. Prompts won't have colour at all, and there's probably no tab completion, unless emacs is doing some magic to provide completions separately. |
|
It looked like the event loop integration worked (had prompt back, could pan/zoom). emacs does it's own colorization, history, and if set up correctly, completion (via jedi). |
Does multiline input works ? (Sidenote, thanks all for pitching in and helping with this) |
|
multiline does not work, but it never worked very well before (did not cope with the indents right and multi-line scroll back did not work). For multi-line stuff it is better to write it in another buffer and ship it over to the interpreter anyway. Completion seems to work better now. |
It is not a terminal emulator. It treats the subprocess as something that simply emits line-based text to stdout and reads line-based text back. The subprocess should not treat it as a terminal emulator, and should not send terminal commands. This is why you check
It's just a wrapper around standard Emacs' There's an IPython/Jupyter notebook implementation for Emacs which might be more useful for some use cases. (Again, I do not use IPython at all, so I am just trying to answer questions by guesswork here :-)) |
As promised, I am surprised. "I wrote that code and I don't know how it's doing what you say it's doing" surprised ;-) Unless it was using the tk backend, as Python automatically integrates with the tkinter event loop without us needing to do anything. If it does what you want and you don't need our completions or multiline input, maybe we should make that a more official feature rather than an internal testing flag. |
|
Now that #9506 is "merged" I think we can get that in. @takluyver, need some help to rebase ? |
IPython now uses the prompt_toolkit based TerminalInteractiveShell instead, so this removes the readline code we're no longer using.
|
Rebased |
| InteractiveShellABC.register(TerminalInteractiveShell) | ||
| class TerminalInteractiveShell(PromptToolkitShell): | ||
| def __init__(self, *args, **kwargs): | ||
| warn("This is a deprecated alias for IPython.terminal.ptshell.TerminalInteractiveShell. " |
There was a problem hiding this comment.
Want to also warn on import ? Can be done in separate PR + since when it is deprecated.
|
Merged ! I'll open a small extra issue to improve deprecation warning and add them on import as well. |


IPython now uses the prompt_toolkit based TerminalInteractiveShell instead, so this removes the readline code we're no longer using.