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"
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):
c = commentc
if len(w.buffer.lines[y]) < x:
c += ' ' * (x - len(w.buffer.lines[y]))
w.buffer.insert_string(Point(x, y), c)
if len(w.buffer.lines[y]) < lvl:
pad = lvl - len(w.buffer.lines[y])
x = lvl - pad
else:
pad = 0
x = lvl
w.buffer.insert_string(Point(x, y), ' ' * pad + c)
class UncommentRegion(Method):
'''Remove a comment from every line in the current buffer'''
@ -806,17 +809,11 @@ class JustifyLeft(Method):
class Undo(Method):
'''Undo last action'''
def _execute(self, w, **vargs):
try:
w.undo()
except Exception, e:
w.set_error("%s" % (e))
class Redo(Method):
'''Redo last undone action'''
def _execute(self, w, **vargs):
try:
w.redo()
except Exception, e:
w.set_error("%s" % (e))
class UnindentBlock(Method):
'''Prepend a tab of space to each line in region'''