help-gnu-emacs
[Top][All Lists]
Advanced

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

python-mode's broken indentation behavior


From: Florian Weimer
Subject: python-mode's broken indentation behavior
Date: Sun, 28 Jun 2015 21:47:03 +0200

Indentation in python-mode has been fairly broken for me, I believe
since Emacs 24.  The electric colon makes this especially annoying.

In the following, _ marks the position of point.

If I press RET here:

def foo(x):
    if x:
        return 2
    else:
        raise Foo_

I get this, which is correct.

def foo(x):
    if x:
        return 2
    else:
        raise Foo
    _

Continuing typing:

def foo(x):
    if x:
        return 2
    else:
        raise Foo
    for i in range(0, 10)_

So far, so good.  Now press ‘:’:

def foo(x):
    if x:
        return 2
    else:
        raise Foo
        for i in range(0, 10):_

Going from:

def foo(x):
    if x:
        x()
    else:
        y()
    for i in range(0, 10)_

to:

def foo(x):
    if x:
        x()
    else:
        y()
        for i in range(0, 10):_

is equally unhelpful.

For me, this makes editing Python scripts with Emacs a fairly painful
experience.

Surely this is a known issue because it has been around for so long.
Is this the behavior the python-mode maintainers prefer?  I find this
hard to believe.


reply via email to

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