Non-indenting colon

Bug #1207405 reported by Barry Warsaw on 2013-08-01
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Medium
Andreas Roehler

Bug Description

def foo(bar):
    for i in range(10):
        print(i)
    tied = bar[

Put point on the last line, after the open bracket. Hit colon (as if you were going to type bar[:]). The line gets incorrectly indented to under the `print`.

There may be other situations where colons should not re-indent the line.

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.1.2
importance: Undecided → Medium
Andreas Roehler (a-roehler) wrote :

Hmm, AFAIU `print' does not close the `for'-loop, so such assignment seems possible at that place(?) Electric-colon always will choose the rightmost thinkable.

Will provide a menu toggling `py-electric-colon-active-p' in any case.

Andreas

Changed in python-mode:
status: New → In Progress

On Aug 07, 2013, at 06:59 PM, Andreas Roehler wrote:

>Hmm, AFAIU `print' does not close the `for'-loop, so such assignment
>seems possible at that place(?)

Correct, but that's not the point.

>Electric-colon always will choose the rightmost thinkable.
>
>Will provide a menu toggling `py-electric-colon-active-p' in any case.

The point is that not all colons are "indenting colons". In this case, the
colon doesn't introduce a new stanza, it separates indexes in a slice, so I
don't think it should change the indentation of the line regardless of the
value of py-e-c-a-p. Toggling that variable isn't helpful because you usually
want electric colons, but only for those which have stanza-opening semantics.

Andreas Roehler (a-roehler) wrote :

Am 12.08.2013 16:43, schrieb Barry Warsaw:
> On Aug 07, 2013, at 06:59 PM, Andreas Roehler wrote:
>
>> Hmm, AFAIU `print' does not close the `for'-loop, so such assignment
>> seems possible at that place(?)
>
> Correct, but that's not the point.
>
>> Electric-colon always will choose the rightmost thinkable.
>>
>> Will provide a menu toggling `py-electric-colon-active-p' in any case.
>
> The point is that not all colons are "indenting colons". In this case, the
> colon doesn't introduce a new stanza,

Okay, may implement that rule:

electric indent colon only when opening a block.

Changed in python-mode:
status: In Progress → Fix Committed
Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers