comment-region fixes

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2009-06-11 00:26:43 -04:00
parent f6313f23c0
commit 883b8d51e5
1 changed files with 11 additions and 14 deletions

View File

@ -537,14 +537,17 @@ class CommentRegion(Method):
w.input_line = "Empty kill region" w.input_line = "Empty kill region"
return return
commentc = w.mode.commentc or '#' c = w.mode.commentc or '#'
lvl = w.buffer.detect_indent_level(p1.y, p2.y) or 0
x = w.buffer.detect_indent_level(p1.y, p2.y) or 0
for y in range(p1.y, p2.y): for y in range(p1.y, p2.y):
c = commentc if len(w.buffer.lines[y]) < lvl:
if len(w.buffer.lines[y]) < x: pad = lvl - len(w.buffer.lines[y])
c += ' ' * (x - len(w.buffer.lines[y])) x = lvl - pad
w.buffer.insert_string(Point(x, y), c) else:
pad = 0
x = lvl
w.buffer.insert_string(Point(x, y), ' ' * pad + c)
class UncommentRegion(Method): class UncommentRegion(Method):
'''Remove a comment from every line in the current buffer''' '''Remove a comment from every line in the current buffer'''
@ -806,17 +809,11 @@ class JustifyLeft(Method):
class Undo(Method): class Undo(Method):
'''Undo last action''' '''Undo last action'''
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
try:
w.undo() w.undo()
except Exception, e:
w.set_error("%s" % (e))
class Redo(Method): class Redo(Method):
'''Redo last undone action''' '''Redo last undone action'''
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
try:
w.redo() w.redo()
except Exception, e:
w.set_error("%s" % (e))
class UnindentBlock(Method): class UnindentBlock(Method):
'''Prepend a tab of space to each line in region''' '''Prepend a tab of space to each line in region'''