From ea98b0a81205fbd7304a4a856fffefbb544f0d37 Mon Sep 17 00:00:00 2001 From: moculus Date: Sat, 1 Mar 2008 17:10:07 +0000 Subject: [PATCH] better mutt/wrapping support --HG-- branch : pmacs2 --- method/__init__.py | 11 +++++++---- mode/mutt.py | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/method/__init__.py b/method/__init__.py index eb43d82..3b02b08 100644 --- a/method/__init__.py +++ b/method/__init__.py @@ -787,8 +787,6 @@ class WrapParagraph(WrapLine): w.goto(Point(x, y)) class WrapParagraph2(Method): limit = 80 - wrapper = WrapLine - spacer = InsertSpace empty_re = regex.whitespace prefix_re = None def _execute(self, w, **vargs): @@ -855,11 +853,16 @@ class WrapParagraph2(Method): # translate our cursor according to the line breaks we just did. (x, y) = oldc.xy() k = 0 - while x > len(newlines[k]): + while k < len(newlines) and x > len(newlines[k]): x = x - len(newlines[k]) - 1 y += 1 k += 1 - #raise Exception, (x, y) + + # if our cursor is on a new line (past all the newlines) then we should + # be inserting another line so that we preserve the spacing of the + # document. + if k == len(newlines): + newlines.append('') # kill the old paragraph region, insert the new, and goto the new cursor w.kill(p1, Point(len(w.buffer.lines[i-1]), i-1)) diff --git a/mode/mutt.py b/mode/mutt.py index 3ce458f..702e425 100644 --- a/mode/mutt.py +++ b/mode/mutt.py @@ -43,10 +43,10 @@ class Mutt(mode.Fundamental): class MuttWrapLine(method.WrapLine): limit = 72 -#class MuttWrapParagraph(method.WrapParagraph): class MuttWrapParagraph(method.WrapParagraph2): - wrapper = MuttWrapLine - empty_re = re.compile('^[ >\n]*$') + wrapper = MuttWrapLine + limit = 72 + empty_re = re.compile('^(?: *>.*| *)$') class MuttInsertSpace(mode.text.TextInsertSpace): limit = 72