py-electric-colon indents incorrect and leaves point at the wrong place

Bug #837065 reported by Barry Warsaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Medium
Andreas Roehler

Bug Description

-----snip snip-----
class TestJoin(unittest.TestCase):
    def tearDown(self):
        reset_the_world()

    def join_user_with_bogus_id(self)
-----snip snip-----

Put point after the paren on the last line and hit colon. The line is incorrectly indented to under the `reset_the_world()` line, and point is left on the `d` of `def`.

Related branches

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.0.3
importance: Undecided → Medium
Revision history for this message
Andreas Roehler (a-roehler) wrote :

Hi Barry,

can't see the bug. Maybe we must negotiate what "electric" means or should mean in the context.

As Emacs can't know reliable what the wished indent will be, it can only guess. So electric indents to the outmost reasonable indent. It leaves point at the current-indent column, to enable a backspace.

Result here is:

class TestJoin(unittest.TestCase):
    def tearDown(self):
        reset_the_world()

        def join_user_with_bogus_id(self):

After electric indent it ends up as above, BTW as you described.
So in the example given, if you don't want a further indent, don't call electric colon, but simple colon
C-u :

? :)

Cheers,

Andreas

Revision history for this message
Georg Brandl (gbrandl) wrote :

Hmm, if that's what the electric colon does, I can't see how it could ever be useful.

Revision history for this message
Andreas Roehler (a-roehler) wrote :

may implement any rule...

what about:

indent to previous defs indent?

Revision history for this message
Barry Warsaw (barry) wrote : Re: [Bug 837065] Re: py-electric-colon indents incorrect and leaves point at the wrong place

On Aug 30, 2011, at 06:22 PM, Andreas Roehler wrote:

>may implement any rule...
>
>what about:
>
>indent to previous defs indent?

Let's step back a second and consider Georg's comment #2. py-electric-colon
was disabled by default because it never really did a good job of
indentation. As you observe, there are many times when it cannot really know
what you want. If electric colon causes more pain than gain, is it worth
adding the keybinding by default?

Andreas, what situations do you find electric colon helping you with?

I can't remember when it was disabled, but it seems like I've been using
python-mode for ages without electric colon and not missing it much. ;)

What do you think about going back to disabling the keybinding by default?
The command will still be there of course, for users to bind it if they want.

Maybe even conduct a query on python-mode@ mailing list to see who uses it?

Revision history for this message
Andreas Roehler (a-roehler) wrote :

Am 30.08.2011 22:26, schrieb Barry Warsaw:
> On Aug 30, 2011, at 06:22 PM, Andreas Roehler wrote:
>
>> may implement any rule...
>>
>> what about:
>>
>> indent to previous defs indent?
>
> Let's step back a second and consider Georg's comment #2. py-electric-colon
> was disabled by default because it never really did a good job of
> indentation. As you observe, there are many times when it cannot really know
> what you want. If electric colon causes more pain than gain, is it worth
> adding the keybinding by default?
>
> Andreas, what situations do you find electric colon helping you with?
>
> I can't remember when it was disabled, but it seems like I've been using
> python-mode for ages without electric colon and not missing it much. ;)
>
> What do you think about going back to disabling the keybinding by default?

think that's the best solution.
Will make a variable for that, so should someone want to have it, might
be enabled.

> The command will still be there of course, for users to bind it if they want.
>
> Maybe even conduct a query on python-mode@ mailing list to see who uses
> it?
>

Changed in python-mode:
status: New → In Progress
Changed in python-mode:
status: In Progress → Fix Committed
Revision history for this message
Barry Warsaw (barry) wrote :

On Aug 31, 2011, at 05:27 AM, Andreas Roehler wrote:

>think that's the best solution.
>Will make a variable for that, so should someone want to have it, might
>be enabled.

Cool. And the choice of C-c / looks good too.

Thanks!

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.