[Python-bugs-list] [ python-Bugs-587239 ] python-mode and nested indents

noreply@sourceforge.net noreply@sourceforge.net
Fri, 26 Jul 2002 14:14:51 -0700


Bugs item #587239, was opened at 2002-07-26 16:56
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=587239&group_id=5470

Category: Demos and Tools
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Andrew Koenig (arkoenig)
Assigned to: Nobody/Anonymous (nobody)
Summary: python-mode and nested indents

Initial Comment:
Using Python-mode 4.6 and GNU emacs 21.2.2, I enter the
following:

if x < 0:
    for i in range(100):
        print i
else:
    print "x is negative"

If I now put the cursor on the "else:" line and hit
tab, it erroneously changes the indentation to line the
"else" up with the "for" above it.


----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2002-07-26 17:14

Message:
Logged In: YES 
user_id=31435

Andrew, why is that erroneous?  Loops in Python have 
(optional) "else:" clauses too.  There's no way for pymode to 
guess whether you intended the else to go with the if or the 
for.  I expect it looks backward for the closest-preceding 
construct the else-statement could "belong to", and finds 
the for-loop first.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=587239&group_id=5470