Matthias Bussonnier added the comment:

> IPython3 solved this issue by adding special magic functions, but this is not 
> a way for CPython.

IPython 5 improve on that with prompt toolkit. It does not break paste, as 
prompt_toolkit has a bracketed-past mode, that most terminal emulator support  
(control chars sent by terminal "hey I'm pasting", "hey I'm done pasting"). So 
it works nicely. IPython 6 even will remove the need for magics to activate 
paste mode.

Though it's far from trivial to implement and to get it "right".

Once you start giving indentation to user, they start to be demanding, like 
indenting 1 more on `:`, and one less on `return`, `pass`... , multiple line 
string. etc...

See https://github.com/ipython/ipython/issues/9283 for some of the issues and 
limitation you can hit.

If you decide to implement this kind of things, there are likely a lot you can 
borrow from IPython, the InputSplitter class has likely the sate needed to give 
you the indent level to use in readline.

----------
nosy: +mbussonn

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29339>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to