An Emacs mode for editing Python code

Bogus whitespace left in docstring after wrapping

Reported by Barry Warsaw on 2013-05-09
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Medium
Andreas Roehler

Bug Description

r1225

def foo():
    """Line one of a comment.

    A paragraph of comments.
    These should get wrapped correctly.
    They do, but whooboy!

    Last line of comment.
    """

Put point somewhere in the middle paragraph and hit M-q (fill-paragraph).

The paragraph gets properly wrapped, but the blank line before it and after it get additional 4 bogus spaces at the beginning of their lines.

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

Hi Barry,

the docstring get's indented as such. I.e. it get's the indentation a C-j from inside would make.
Do you think that's wrong? Is there a case where it disturbs?

Cheers,

Andreas

On May 13, 2013, at 05:28 PM, Andreas Roehler wrote:

>the docstring get's indented as such. I.e. it get's the indentation a C-j
>from inside would make. Do you think that's wrong? Is there a case where it
>disturbs?

Yes. Take the following example:

def foo():
    """This is the foo method.

    The foo method does stuff.
    It does other stuff too.
    Oh, but it does not do some other stuff.

    Use the foo method with caution.
    """

In this case, you'll notice that the blank lines surrounding the middle
paragraph are indeed blank. No indentation is present.

Now use M-q to re-fill the middle paragraph. The separating lines suddenly
grow 4 leading spaces making them non-empty. Normally, you can't see the
spaces unless you turn on global-whitespace-mode or similar, but that makes
the problem worse.

Imagine you have a unit test that requires those lines to be really blank,
i.e. empty. M-q would break those tests.

Thus, it is critical that filling a paragraph not change the indentation of
the surrounding blank lines.

Changed in python-mode:
status: New → In Progress
Andreas Roehler (a-roehler) wrote :

Thanks for the explanation. Fix follows.

Andreas

Changed in python-mode:
status: In Progress → Fix Committed
Barry Warsaw (barry) wrote :

Re-opening because this one seems to be back again in current bzr head. r1271

Changed in python-mode:
status: Fix Committed → New
Changed in python-mode:
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  Edit
Everyone can see this information.

Other bug subscribers