[IPython-dev] smart indent, multiline statement history and multiline statement edition

Vivian De Smedt vivian at vdesmedt.com
Sun Oct 2 11:25:31 CDT 2005


Fernando,

I suppose you didn't had the time to have look at the patch I submit 
that according to me at least improve the usability of the python 
debugger in the spirit of IPython but it is not for that that I write 
this mail.

In my quest to contribute I would like to improve IPython in two areas:
 - copy and paste
 - multiline edition

1.) By improving IPython for copy and paste I mean try to find a way to 
paste multiline statement when autoindent is on.
What I had in mind is the following:

Since autoindent is pretty enough to propose you identation each time 
you could need one or to say it differently when autoindent is on the 
tab touch is unnecessary I propose a smartindent mode (which could just 
the autoindent mode if you like it).

In that mode the autoindent proposition of leading space is forgotten if 
the first character of a line is a space or a tabulation.

In such mode autoindentation is working more or less the same way as 
before but if you copy a bunch of code from elsewhere it will be paste 
with the original indentation.

Let me know what you think about this proposition, if you did try such 
aproach in the paste and if so what was the techincal difficulties you 
faced (I guess here the various implementation of readline will play 
they role and I will have to test my patch against each of them before 
submision).

2.) I would like to improve multiline support. I have various ideas some 
modest some more ambitious.

The first is just about the history of the command. Now when you type a 
multiline statement each line of the statement is a separate entry in 
the command history.

def foo(bar):
    bar += 3
    return bar * 2

However the chance that you are interested by the line "    return bar * 
2" by itself is not big.

My proposition was that only the first "def foo(bar)" was visible in the 
command history and that when you choose it (hit return) the next one 
("    bar += 3", "    return bar * 2") appear in the forward part of the 
history such that you can quickly review a multiline statement.

Here is a small scenario illustration the usage of my proposition:

def foo(bar):
    bar += 3
    return bar * 2

[up-arrow]
edit the first line of the multiline statement
[return]
[down-arrow]
edit the second  line of the multiline statement
[return]
[down-arrow]
edit the third line of the multiline statement
[return]

Let me know if it is clear, if you like it, if you think it could be 
usefull if you think it is feasible.

Vivian.




More information about the IPython-dev mailing list