fixed comment wrapping in perl

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2010-04-20 01:38:32 -04:00
parent 55a578a507
commit 3fbd26f5d4
1 changed files with 7 additions and 22 deletions

View File

@ -573,11 +573,6 @@ class PerlWrapParagraph(WrapParagraph):
margin = 80 margin = 80
comment_re = re.compile('( *)(#+)( *)(.*)') comment_re = re.compile('( *)(#+)( *)(.*)')
def _is_newline(self, t):
return t.name == 'eol'
def _is_space(self, t):
return t.name == 'spaces'
def _detect_line_type(self, w, y): def _detect_line_type(self, w, y):
h = w.buffer.highlights[w.mode.name] h = w.buffer.highlights[w.mode.name]
ltype = None ltype = None
@ -585,20 +580,13 @@ class PerlWrapParagraph(WrapParagraph):
fqname = t.fqname() fqname = t.fqname()
if fqname == 'spaces' or fqname == 'eol': if fqname == 'spaces' or fqname == 'eol':
pass pass
elif fqname.startswith('comment'): elif fqname == 'perl.comment':
if ltype and ltype != 'comment': return self.LT_COMMENT
ltype = None elif fqname.startswith('perl.pod'):
break return self.LT_POD
ltype = self.LT_COMMENT
elif fqname.startswith('pod'):
if ltype and ltype != 'pod':
ltype = None
break
ltype = self.LT_POD
else: else:
ltype = None return None
break return None
return ltype
def _fix_comments(self, c, w): def _fix_comments(self, c, w):
y1 = c.y y1 = c.y
@ -613,7 +601,7 @@ class PerlWrapParagraph(WrapParagraph):
m = self.comment_re.match(lines[0]) m = self.comment_re.match(lines[0])
assert m assert m
prepend = m.group(1) + m.group(2) prepend = m.group(1) + m.group(2)
rmargin = self.margin - len(prepend) rmargin = self.margin - len(prepend) - 1
dpad = m.group(3) dpad = m.group(3)
segments = [] segments = []
@ -648,9 +636,6 @@ class PerlWrapParagraph(WrapParagraph):
w.buffer.insert_lines(p1, lines2) w.buffer.insert_lines(p1, lines2)
w.set_error("wrapped comment lines %d-%d" % (y1 + 1, y2 + 1)) w.set_error("wrapped comment lines %d-%d" % (y1 + 1, y2 + 1))
def _fix_pod(self, c, w):
w.set_error("pod wrapping not yet supported")
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
c = w.logical_cursor() c = w.logical_cursor()
ltype = self._detect_line_type(w, c.y) ltype = self._detect_line_type(w, c.y)