Subject: bug#25306: emacs 25.1 cannot deal with the newer ipython (5.1.0) inferior ansi color

From: Maxim Cournoyer <[email-masked]>
Date: Sun, 21 May 2017 16:35:47 -0700

Correct me if this is not what the original bug is about, but it seems
that to reproduce this, one can:

1. Install latest ipython: "pip install -U ipython"
2. Evaluate the following (setq python-shell-interpreter "ipython"
                                python-shell-interpreter-args "")
3. M-x run-python

You should see special characters used by ipython appear at the prompt
already, like:

--8<---------------cut here---------------start------------->8---
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

[6n[JIn [1]: [8D[8C[8D[J[6n[JIn [1]: [8D[8C
--8<---------------cut here---------------end--------------->8---

It seems those would be a mix of color and control ANSI escape codes
[0]. The dumb shells based on comint do not support ANSI. I'm not sure
supporting these would be desirable as part of comint. It seems that in
the context of emacs, the answer is no; Emacs comes with its own
facilities for line editing; and using those for every command
interpreter makes the experience consistent.

In this particular case, there exists an option to tell IPython to
refrain from sending ANSI codes, and that option is
"--simple-prompt". It does have a few limitations though. The ones which
I know are:

1. No multi-line editing support. [1]
2. Doesn't set up an event loop, which breaks when using
ipdb.set_trace() [2]

For these reasons maybe it would make sense to have a facility simply
"strip" all the ANSI escape codes from the responses (and not use the
"--simple-prompt" until the quirks get ironed out).

Thoughts?

Maxim

[0] https://en.wikipedia.org/wiki/ANSI_escape_code
[1] https://github.com/ipython/ipython/issues/9816
[2] https://github.com/ipython/ipython/issues/10577