parent
00edb537b3
commit
7ea3fd3855
40
mode/perl.py
40
mode/perl.py
|
@ -406,6 +406,45 @@ class PerldocWord(Perldoc):
|
|||
return
|
||||
return Perldoc._execute(self, w, name=word)
|
||||
|
||||
class PerlQuoteWord(Method):
|
||||
word_re = re.compile('^[a-zA-Z0-9_]+$')
|
||||
def _execute(self, w, **vargs):
|
||||
t = w.get_token()
|
||||
if t.fqname().endswith('string.data'):
|
||||
return w.set_error('word is already quoted')
|
||||
word = t.string
|
||||
if word is None:
|
||||
return w.set_error('no word selected')
|
||||
if not self.word_re.match(word):
|
||||
return w.set_error('not a perl word: %r' % word)
|
||||
|
||||
w.insert_string(Point(t.x, t.y), "'")
|
||||
w.insert_string(Point(t.end_x(), t.y), "'")
|
||||
|
||||
class PerlDequoteWord(Method):
|
||||
word_re = re.compile('^[a-zA-Z0-9_]+$')
|
||||
def _execute(self, w, **vargs):
|
||||
p = w.logical_cursor()
|
||||
x1, x2 = p.x, p.end_x()
|
||||
tokens = w.get_line_token_list_at_point(p)
|
||||
data_token = None
|
||||
saw_start = False
|
||||
for token in tokens:
|
||||
if token.end_x() < x1:
|
||||
continue
|
||||
elif token.fqname().endswith('string.start'):
|
||||
saw_start = True
|
||||
elif token.fqname().endswith('string.data'):
|
||||
data_token = token
|
||||
elif saw_start:
|
||||
break
|
||||
|
||||
if not data_token:
|
||||
w.set_error('no suitable quoted word found!')
|
||||
return
|
||||
|
||||
w.set_error('going to dequote %r' % token.data)
|
||||
|
||||
class PerlInitFunctions(Method):
|
||||
'''Jump to a function defined in this module'''
|
||||
def _execute(self, w, **vargs):
|
||||
|
@ -882,6 +921,7 @@ class Perl(Fundamental):
|
|||
PerldocWord, Perldoc, PerldocF, PerlWrapParagraph, PerlInitFunctions,
|
||||
PerlGotoFunction, PerlWhichFunction, PerlListFunctions, PerlOpenModule,
|
||||
PerlOpenModuleWord, PerlSemanticComplete,
|
||||
PerlQuoteWord, PerlDequoteWord,
|
||||
]
|
||||
completers = {
|
||||
'perlfunction': PerlFunctionCompleter(None),
|
||||
|
|
Loading…
Reference in New Issue