lowercase/uppercase, and some bug fixes
--HG-- branch : pmacs2
This commit is contained in:
parent
525f1e70f9
commit
27b1a17e7b
|
@ -324,6 +324,22 @@ class DeleteRightSpace(Method):
|
||||||
if p > c:
|
if p > c:
|
||||||
w.delete(c, p)
|
w.delete(c, p)
|
||||||
|
|
||||||
|
# errata
|
||||||
|
class LowercaseWord(Method):
|
||||||
|
'''Lowercase all characters in word'''
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
(p1, p2) = w.get_word_bounds()
|
||||||
|
word = w.buffer.get_substring(p1, p2)
|
||||||
|
w.delete(p1, p2)
|
||||||
|
w.insert_string(p1, word.lower())
|
||||||
|
class UppercaseWord(Method):
|
||||||
|
'''Uppercase all characters in word'''
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
(p1, p2) = w.get_word_bounds()
|
||||||
|
word = w.buffer.get_substring(p1, p2)
|
||||||
|
w.delete(p1, p2)
|
||||||
|
w.insert_string(p1, word.upper())
|
||||||
|
|
||||||
class MetaX(Method):
|
class MetaX(Method):
|
||||||
'''Invoke commands by name'''
|
'''Invoke commands by name'''
|
||||||
args = [arg('method', dt="method", p="M-x ", h='Method to execute')]
|
args = [arg('method', dt="method", p="M-x ", h='Method to execute')]
|
||||||
|
|
|
@ -234,6 +234,9 @@ class Fundamental(Handler):
|
||||||
self.add_bindings('increment', ('M-+',))
|
self.add_bindings('increment', ('M-+',))
|
||||||
self.add_bindings('decrement', ('M--',))
|
self.add_bindings('decrement', ('M--',))
|
||||||
|
|
||||||
|
self.add_bindings('uppercase-word', ('M-u',))
|
||||||
|
self.add_bindings('lowercase-word', ('M-l',))
|
||||||
|
|
||||||
# used for all word operations
|
# used for all word operations
|
||||||
if not self.word_letters:
|
if not self.word_letters:
|
||||||
self.word_letters = w.application.config['word_letters']
|
self.word_letters = w.application.config['word_letters']
|
||||||
|
|
|
@ -525,6 +525,7 @@ class PerlOpenModule(method.Method):
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
path = w.mode.find_module(vargs['module'])
|
path = w.mode.find_module(vargs['module'])
|
||||||
if path:
|
if path:
|
||||||
|
w.set_error("opening %r..." % path)
|
||||||
w.application.methods['open-file'].execute(w, filename=path)
|
w.application.methods['open-file'].execute(w, filename=path)
|
||||||
else:
|
else:
|
||||||
w.set_error("Could not find module %r" % vargs['module'])
|
w.set_error("Could not find module %r" % vargs['module'])
|
||||||
|
@ -545,6 +546,7 @@ class PerlOpenModuleWord(method.Method):
|
||||||
else:
|
else:
|
||||||
pkg = parent
|
pkg = parent
|
||||||
if path:
|
if path:
|
||||||
|
w.set_error("opening %r..." % path)
|
||||||
w.application.methods['open-file'].execute(w, filename=path)
|
w.application.methods['open-file'].execute(w, filename=path)
|
||||||
else:
|
else:
|
||||||
w.set_error("Could not find module related to %r" % word)
|
w.set_error("Could not find module related to %r" % word)
|
||||||
|
|
|
@ -368,12 +368,13 @@ class Window(object):
|
||||||
if p is not None:
|
if p is not None:
|
||||||
self.goto(p)
|
self.goto(p)
|
||||||
def get_word_bounds_at_point(self, p):
|
def get_word_bounds_at_point(self, p):
|
||||||
|
wl = self.mode.word_letters
|
||||||
if len(self.buffer.lines[p.y]) == 0:
|
if len(self.buffer.lines[p.y]) == 0:
|
||||||
return None
|
return None
|
||||||
elif self.cursor_char() not in wl:
|
elif self.cursor_char() not in wl:
|
||||||
return None
|
return None
|
||||||
x1 = x2 = p.x
|
x1 = x2 = p.x
|
||||||
while x1 > 0 and self.xy_char(x1 - 1, p.y) in self.mode.word_letters:
|
while x1 > 0 and self.xy_char(x1 - 1, p.y) in wl:
|
||||||
x1 -= 1
|
x1 -= 1
|
||||||
while x2 < len(self.buffer.lines[p.y]) and self.xy_char(x2, p.y) in wl:
|
while x2 < len(self.buffer.lines[p.y]) and self.xy_char(x2, p.y) in wl:
|
||||||
x2 += 1
|
x2 += 1
|
||||||
|
|
Loading…
Reference in New Issue