[IPython-user] autoindentation problem in emacs
Fernando.Perez at colorado.edu
Sat Mar 25 18:02:48 CST 2006
Alexander Schmolck wrote:
> Fernando Perez <Fernando.Perez at colorado.edu> writes:
>>Sorry not to have a solution, but if an enterprising elisp coder knows how to
>>fix this, patches are welcome.
> Firstly -- the spaces or tabs are still printed by ipython even when running
> in a dumb emacs terminal?
Nope (xemacs -nw):
In : if 1:
...: print 'hi'
> I had a brief look, but I suspect it might be tricky, because I'm not sure how
> well this behaviour works with comint's idea of what a prompt is. The
> additional whitespace both belongs to the prompt (because the cursor should
> come after it in the new line) and doesn't (because you can delete it to
> dedent back to scratch; comint normally prevents deleting into the prompt).
> The easiest fix might be to disable autoindent in ipython and override the
> behaviour of the return key to indedent by a tab if the line ends with a colon
> and to repeat the current indentation of the previous line, but that's not
> entirely pleasing.
Not too pleasing, but it looks the only solution. Autoindent (with proper
visual feedback) relies on readline's ability to manipulate the input line.
Emacs won't let that be done, as it has its own mechanisms for the same (used
by python-mode when coding, for example). If the ipython terminal could just
use python-mode's facilities, I guess that would be great. But I don't know
if that is possible.
More information about the IPython-user