I make much use of sub-shells within Emacs (initiated via M-x shell
), and, because of this, I run into problems like the one illustrated1 below way too often:
$ python -m pdb /tmp/hello_world.py
[2] > /tmp/hello_world.py(1)<module>()
-> print 'Hello, world!'
^[[1A
(Pdb++) l
^[[1@l^[[9D
1 -> print 'Hello, world!'
[EOF]
^[[1A
(Pdb++) quit()
^[[1@q^[[1@u^[[1@i^[[1@t^[[1@(^[[1@)^[[14D
$
In a regular terminal, the same interaction looks like this:
$ python -m pdb /tmp/hello_world.py
> /tmp/hello_world.py(1)<module>()
-> print 'Hello, world!'
(Pdb) l
1 -> print 'Hello, world!'
[EOF]
(Pdb) quit()
$
Whenever this sort of thing happens I resort to Google, and start trying the random fixes I find, more or less blindly, until one works, if any.
In this example, I've run python
within an interactive debugger, all under a sub-shell, under Emacs (yes, it's quite a tower I've got here).
Here, Python's side of the interaction includes several escaped characters (preceded by ^[
) that are not properly displayed.
Whenever this happens I resort to Google, and start trying the random fixes I find, more or less blindly, until one works, if any.
Is there a more systematic way to troubleshoot, diagnose, and (hopefully) fix such problems?
1In the display above, I've simulated things by rendering some characters the way they appear on my screen. Namely, I used two normal characters ^
and [
to display what is actually a single character, namely ASCII 27, aka ESC
.