Python vs emacs (again...)

Tim Lesher tim at lesher.ws
Wed Jun 4 16:09:00 EDT 2003


I downloaded the newest python-mode.el from SourceForge, and found (to
my delight) that Bernhard Herzog's paragraph-filling code has been
added.  Big win, IMHO, and a big improvement over the native filling.

However, there are still some sharp edges to how it works.  Consider:

0: def fn(a):
1:     """This function has
2:     a docstring with one short line and one really, really, really,
spam, eggs, shiitake mushrooms, spam long line."""
3:     #Not to mention a comment
4:     #that needs filling
5:     return a / 0

Now the behavior of fill-paragraph is dependent on the position of
point when you call it.  If it's anywhere on line zero, you get the
well-known "crunching":

def fn(a): """This function has a docstring with one short line and
    one really, really, really, spam, eggs, shiitake mushrooms, spam
    long line."""  #Not to mention a comment #that needs filling
    return a / 0

(Note that even this is better than the crunching you get with the
default fill-paragraph--at least it doesn't fill the return line in
with the comments, so it remains legal python code).

If point is at line one before the triple-quote, it also crunches.  If
it's between the first and third quote, nothing happens, and if it's
after the third quote, it does the right thing.

If point is anywhere on the commented lines (3 or 4), it does the
right thing.

If point is on the last line, we're back to crunching.

To summarize:  this is much, much better than the default, but it's
still not quote optimal.  Is this as good as can be hoped for with the
facilities emacs provides?




More information about the Python-list mailing list