return key doesn't maintain current indentation level

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

Bug Description

Suppose I have code like this

def f():
    return 42

[CURSOR]

Notice my cursor is flush with the left margin. Hitting return creates this situation:

def f():
    return 42

    [CURSOR]

Notice the cursor has been indented to level of the function body. This shouldn't happen. Rather a newline should simply be inserted without indenting further.

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

Can't reproduce. RET as also C-j place cursor in column 0. See png attached.

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

Sorry, it only happens if there's not a "return" in the function body like this:

def f():
    x = 42

[CURSOR]

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 1095147] Re: return key doesn't maintain current indentation level

Am 02.01.2013 15:45, schrieb Benjamin Peterson:
> Sorry, it only happens if there's not a "return" in the function body
> like this:
>
> def f():
> x = 42
>
> [CURSOR]
>

okay, well, that's a very old story.

See comment in python-mode-map:

         ;; Most Pythoneers expect RET `py-newline-and-indent'

Personally I've just newline.
May introduce an option, enabling a change of this setting, mapping RET at newline again.

Changed in python-mode:
milestone: none → 6.1.1
status: New → In Progress
Revision history for this message
Andreas Roehler (a-roehler) wrote :

you may customize py-return-key now
Maybe a restart is needed after in order to take it.

Changed in python-mode:
status: In Progress → Fix Committed
Changed in python-mode:
status: Fix Committed → New
status: New → Fix Committed
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

Bug attachments

Remote bug watches

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