py-newline-and-indent leaves eol whitespace cruft

Bug #1100892 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

py-newline-and-indent leaves extra whitespace at eol if used inside an existing construct. It should instead clean up all trailing whitespace. I believe this is a regression.

To reproduce, turn on global-whitespace-mode and visit this file:

-----snip snip-----
def foo():
    x = some_long_call(supercalifragilistic=6, expialidocious=7)
-----snip snip-----

Now, put point on the 'e' of expialidocious and hit RET

You will see that there's an extra space left after the "6, ". All trailing whitespace should instead be removed.

Revision history for this message
Barry Warsaw (barry) wrote :

On Jan 17, 2013, at 07:36 PM, Andreas Roehler wrote:

>Am 17.01.2013 19:07, schrieb Barry Warsaw:
>> Public bug reported:
>>
>> py-newline-and-indent leaves extra whitespace at eol if used inside an
>> existing construct. It should instead clean up all trailing whitespace.
>> I believe this is a regression.
>
>Auto-delete trailing whitespace was cancelled when fixing lp:1020220
>
>Customizing then introduced py-trailing-whitespace-smart-delete-p to `t'
>should do it. Maybe change the default?

A few comments:

For py-newline-and-indent, I think it is not correct that python-mode delete
all trailing whitespace in the buffer. It should only delete the trailing
whitespace on the line you are editing (specifically: the line on which you
hit RET).

I'm also not sure that the same variable which controls trailing whitespace
cleanup for RET should also control buffer-wide whitespace cleanup on save.
As the docstring for py-t-w-s-d-p says, this can have negative consequences
for editing other people's code.

For example: I always want to clean up the line I'm editing, but I do *not*
want to clean up the entire buffer, since that will introduce lots of cruft
into diffs. If I do want to clean up the entire buffer, I have a separate
function I can call explicitly (or I could put it on a save hook myself).

As for the default, if the save hook side-effect didn't exist, then yes, it
should be t by default.

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 1100892] [NEW] py-newline-and-indent leaves eol whitespace cruft

Am 17.01.2013 19:07, schrieb Barry Warsaw:
> Public bug reported:
>
> py-newline-and-indent leaves extra whitespace at eol if used inside an
> existing construct. It should instead clean up all trailing whitespace.
> I believe this is a regression.

Auto-delete trailing whitespace was cancelled when fixing lp:1020220

Customizing then introduced py-trailing-whitespace-smart-delete-p to `t' should do it.
Maybe change the default?

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.1.1
importance: Undecided → Medium
Changed in python-mode:
status: New → In Progress
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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