[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#15400: Python mode: "eval region" indentation problem

From: Hendrik Weisser
Subject: bug#15400: Python mode: "eval region" indentation problem
Date: Tue, 17 Sep 2013 14:42:54 +0200 (CEST)

Dear developers,

The "eval region" function in Emacs' Python major mode (python.el) has problems 
dealing with indented code.
Consider this example:

1 for i in range(10**10):
2     do_something(i)
3     do_more(i)

When testing such code, it is often useful to evaluate the loop contents for an 
example value of the parameter, rather than running the whole loop. In the 
example, I would like to be able to define a region consisting of lines 2 and 
3, and run them using the "eval region" command (after setting a value for "i" 
in the interpreter). However, this will give me an "IndentationError: 
unexpected indent" in Python (either for the first or the second line, 
depending on whether the region starts at the beginning of line 2 or after the 

It should be possible to resolve such cases by stripping any leading whitespace 
from the first line in the region, and stripping the same amount from each 
following line (provided that the region starts at the beginning of the line). 
I believe this behaviour would be quite intuitive.

Please consider adapting the "eval region" function in this way to increase its 

Best regards


reply via email to

[Prev in Thread] Current Thread [Next in Thread]