commit
6466993ed1
|
@ -209,19 +209,25 @@ class CvsDiff3(Method):
|
||||||
w.set_error("Differences were found")
|
w.set_error("Differences were found")
|
||||||
|
|
||||||
class CvsBlame(Method):
|
class CvsBlame(Method):
|
||||||
'''show blame output for the current version in SVN'''
|
'''show blame output for the current version in CVS'''
|
||||||
line_re = re.compile('^([0-9.]+) +\(*([a-zA-Z0-9_]+) +([-0-9A-Za-z]+)\): (.*)$')
|
line_re = re.compile('^([0-9.]+) +\(*([a-zA-Z0-9_]+) +([-0-9A-Za-z]+)\): (.*)$')
|
||||||
|
def _get_path(self, w, **vargs):
|
||||||
|
cwd = os.getcwd() + os.path.sep
|
||||||
|
path = w.buffer.path
|
||||||
|
if path.startswith(cwd):
|
||||||
|
path = path[len(cwd):]
|
||||||
|
return path
|
||||||
|
|
||||||
|
def _get_cmd(self, w, **vargs):
|
||||||
|
path = self._get_path(w, **vargs)
|
||||||
|
return ("/usr/bin/cvs", 'annotate', path)
|
||||||
|
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
if not hasattr(w.buffer, 'path'):
|
if not hasattr(w.buffer, 'path'):
|
||||||
w.set_error("Buffer has no corresponding file")
|
w.set_error("Buffer has no corresponding file")
|
||||||
return
|
return
|
||||||
|
|
||||||
cwd = os.getcwd() + os.path.sep
|
cmd = self._get_cmd(w, **vargs)
|
||||||
path = w.buffer.path
|
|
||||||
if path.startswith(cwd):
|
|
||||||
path = path[len(cwd):]
|
|
||||||
|
|
||||||
cmd = ("/usr/bin/cvs", 'annotate', path)
|
|
||||||
pipe = Popen(cmd, stdout=PIPE, stderr=PIPE)
|
pipe = Popen(cmd, stdout=PIPE, stderr=PIPE)
|
||||||
|
|
||||||
linetokens = []
|
linetokens = []
|
||||||
|
@ -265,3 +271,11 @@ class CvsBlame(Method):
|
||||||
w.application.color_data_buffer("*Blame*", data, switch_to=True)
|
w.application.color_data_buffer("*Blame*", data, switch_to=True)
|
||||||
else:
|
else:
|
||||||
w.set_error("There was an error (%s)" % (status))
|
w.set_error("There was an error (%s)" % (status))
|
||||||
|
|
||||||
|
class CvsBlame2(CvsBlame):
|
||||||
|
'''show blame output for the current version in CVS'''
|
||||||
|
args = [arg("revision", t=type(""), p="Revision: ", h="revision number")]
|
||||||
|
line_re = re.compile('^([0-9.]+) +\(*([a-zA-Z0-9_]+) +([-0-9A-Za-z]+)\): (.*)$')
|
||||||
|
def _get_cmd(self, w, **vargs):
|
||||||
|
path = self._get_path(w, **vargs)
|
||||||
|
return ("/usr/bin/cvs", 'annotate', '-r', vargs['revision'], path)
|
||||||
|
|
67
mode/perl.py
67
mode/perl.py
|
@ -42,7 +42,7 @@ wchr2 = '[a-zA-Z0-9_]'
|
||||||
wchr3 = '[-a-zA-Z0-9_]'
|
wchr3 = '[-a-zA-Z0-9_]'
|
||||||
hword = wchr3 + '+'
|
hword = wchr3 + '+'
|
||||||
word1 = wchr1 + wchr2 + '*'
|
word1 = wchr1 + wchr2 + '*'
|
||||||
word2 = '(?:' + word1 + '::)*' + word1
|
word2 = '(?:' + word1 + "(?:'|::))*" + word1
|
||||||
pname = '[.a-zA-Z0-9_]+'
|
pname = '[.a-zA-Z0-9_]+'
|
||||||
|
|
||||||
def _make_string_rules(forbidden):
|
def _make_string_rules(forbidden):
|
||||||
|
@ -58,6 +58,14 @@ def _make_string_rules(forbidden):
|
||||||
PatternRule('cast', r"[\$\@\%\&]{.+?}"),
|
PatternRule('cast', r"[\$\@\%\&]{.+?}"),
|
||||||
PatternRule('array', r"@\$*" + word2),
|
PatternRule('array', r"@\$*" + word2),
|
||||||
]
|
]
|
||||||
|
if forbidden == ')':
|
||||||
|
rules.append(PatternRule('data', r"\([^\(\)]*\)"))
|
||||||
|
elif forbidden == '}':
|
||||||
|
rules.append(PatternRule('data', r"{[^{}]*}"))
|
||||||
|
elif forbidden == ']':
|
||||||
|
rules.append(PatternRule('data', r"\[[^\[\]]*\]"))
|
||||||
|
elif forbidden == '>':
|
||||||
|
rules.append(PatternRule('data', r"<[^<>]*>"))
|
||||||
return rules
|
return rules
|
||||||
|
|
||||||
class QuotedWords(Grammar): rules = [
|
class QuotedWords(Grammar): rules = [
|
||||||
|
@ -72,9 +80,14 @@ class NoAngle(Grammar): rules = [PatternRule('data', '[^>]+')]
|
||||||
class NoHash(Grammar): rules = [PatternRule('data', '[^#]+')]
|
class NoHash(Grammar): rules = [PatternRule('data', '[^#]+')]
|
||||||
class DataGrammar(Grammar): rules = [PatternRule('data', '.+')]
|
class DataGrammar(Grammar): rules = [PatternRule('data', '.+')]
|
||||||
|
|
||||||
class StrictStringGrammar(Grammar): rules = [PatternRule('escaped', r"\\'")]
|
class StrictStringGrammar(Grammar): rules = [
|
||||||
class StringGrammar(Grammar): rules = _make_string_rules('"')
|
PatternRule('escaped', r"\\[\\']"),
|
||||||
class EvalGrammar(Grammar): rules = _make_string_rules('`')
|
PatternRule('data', r"[^\\']+"),
|
||||||
|
]
|
||||||
|
class StringGrammar(Grammar):
|
||||||
|
rules = _make_string_rules('"') + [PatternRule('data', '[^\\"]+')]
|
||||||
|
class EvalGrammar(Grammar):
|
||||||
|
rules = _make_string_rules('`') + [PatternRule('data', '[^\\`]+')]
|
||||||
|
|
||||||
class TranslateGrammar1(Grammar):
|
class TranslateGrammar1(Grammar):
|
||||||
rules = [PatternRule('data', r"(?:\\.|[^\\/])")]
|
rules = [PatternRule('data', r"(?:\\.|[^\\/])")]
|
||||||
|
@ -83,6 +96,7 @@ class TranslateGrammar2(Grammar):
|
||||||
class TranslateGrammarX(Grammar):
|
class TranslateGrammarX(Grammar):
|
||||||
rules = [PatternRule('data', r"(?:\\.|[^\\%(delim)s])")]
|
rules = [PatternRule('data', r"(?:\\.|[^\\%(delim)s])")]
|
||||||
|
|
||||||
|
class MatchGrammar0(Grammar): rules = _make_string_rules(None)
|
||||||
class MatchGrammar1(Grammar): rules = _make_string_rules('/')
|
class MatchGrammar1(Grammar): rules = _make_string_rules('/')
|
||||||
class MatchGrammar2(Grammar): rules = _make_string_rules('#')
|
class MatchGrammar2(Grammar): rules = _make_string_rules('#')
|
||||||
class MatchGrammar3(Grammar): rules = _make_string_rules(')')
|
class MatchGrammar3(Grammar): rules = _make_string_rules(')')
|
||||||
|
@ -122,13 +136,26 @@ class PerlGrammar(Grammar):
|
||||||
RegionRule('perl.string', '"', StringGrammar, '"'),
|
RegionRule('perl.string', '"', StringGrammar, '"'),
|
||||||
RegionRule('perl.string', "'", StrictStringGrammar, "'"),
|
RegionRule('perl.string', "'", StrictStringGrammar, "'"),
|
||||||
RegionRule('perl.evalstring', "`", EvalGrammar, "`"),
|
RegionRule('perl.evalstring', "`", EvalGrammar, "`"),
|
||||||
PatternRule('perl.number', r'0?\.[0-9]+|[0-9]+(?:\.[0-9]+)?'),
|
PatternRule('perl.keyword', "(?<!->)(?:STDIN|STDERR|STDOUT|continue|do|else|elsif|eval|foreach|for|if|last|my|next|no|our|package|require|return|sub|undef|unless|until|use|while)(?![a-zA-Z0-9_])"),
|
||||||
PatternRule('perl.keyword', "(?<!->)(?:STDIN|STDERR|STDOUT|continue|do|else|elsif|eval|foreach|for|if|last|my|next|our|package|require|return|sub|undef|unless|until|use|while)(?![a-zA-Z0-9_])"),
|
|
||||||
PatternRule('perl.hash_key', '(?<={)' + wchr2 + '+(?=})'),
|
PatternRule('perl.hash_key', '(?<={)' + wchr2 + '+(?=})'),
|
||||||
PatternRule('perl.method', '(?<=->)' + word1),
|
PatternRule('perl.method', '(?<=->)' + word1),
|
||||||
PatternRule('perl.hash_key', wchr2 + '+(?= *=>)'),
|
PatternRule('perl.hash_key', wchr2 + '+(?= *=>)'),
|
||||||
PatternRule('perl.length', r"\$#" + word2),
|
PatternRule('perl.length', r"\$#" + word2),
|
||||||
PatternRule('perl.cast', r'[\$\@\%\&\*](?= *{)'),
|
PatternRule('perl.cast', r'[\$\@\%\&\*](?= *{)'),
|
||||||
|
|
||||||
|
PatternRule('perl.number', r'0[xX][0-9A-Fa-f]+'),
|
||||||
|
PatternRule('perl.number', r'0?\.[0-9]+|[0-9]+(?:\.[0-9]+)?'),
|
||||||
|
|
||||||
|
# built-in scalars
|
||||||
|
PatternRule('perl.scalar', r'\$[_ab&`\'\+\*\./|,\\";#\%=\-~\^:\?!@\$<>()\[\]](?!' + wchr2 + ')'),
|
||||||
|
PatternRule('perl.scalar', r'\$\d+(?!' + wchr2 +')'),
|
||||||
|
PatternRule('perl.scalar', r'\$\^(?:' + word1 + '|' + wchr1 + ')'),
|
||||||
|
PatternRule('perl.scalar', r'\$\^O'),
|
||||||
|
PatternRule('perl.scalar', r'\${\^' + word1 + '}'),
|
||||||
|
|
||||||
|
PatternRule('perl.array', r'\@[\+\-]'),
|
||||||
|
PatternRule('perl.hash', r'\%(?:[!]|^H)'),
|
||||||
|
|
||||||
PatternRule('perl.scalar', r"\$[\[\]<>ab/'\"_@\?#\$!%^|&*()](?!" +
|
PatternRule('perl.scalar', r"\$[\[\]<>ab/'\"_@\?#\$!%^|&*()](?!" +
|
||||||
wchr2 + ")"),
|
wchr2 + ")"),
|
||||||
PatternRule('perl.array', "@_"),
|
PatternRule('perl.array', "@_"),
|
||||||
|
@ -149,21 +176,13 @@ class PerlGrammar(Grammar):
|
||||||
MatchGrammar6, r'\>[a-z]*'),
|
MatchGrammar6, r'\>[a-z]*'),
|
||||||
|
|
||||||
# match regexes
|
# match regexes
|
||||||
RegionRule('perl.match', r'(?:(?<==~)|(?<=!~)|(?<=\()|(?<=split)|(?<=if)|(?<=unless)|(?<=while)|(?<=until)|(?<=\|\|)) *(?P<delim>/)', MatchGrammar1, '/[a-z]*'),
|
RegionRule('perl.match', r'(?:(?<==~)|(?<=!~)|(?<=\()|(?<=split)|(?<=if)|(?<=unless)|(?<=while)|(?<=until)|(?<=\|\|)|(?<=&&)|(?<==)) *(?P<delim>/)', MatchGrammar1, '/[a-z]*'),
|
||||||
RegionRule('perl.match', 'm *(?P<delim>/)', MatchGrammar1, '/[a-z]*'),
|
RegionRule('perl.match', 'm *(?P<delim>/)', MatchGrammar1, '/[a-z]*'),
|
||||||
RegionRule('perl.match', 'm *(?P<delim>[^ #a-zA-Z0-9_])',
|
RegionRule('perl.match', 'm *(?P<delim>[^ #a-zA-Z0-9_])',
|
||||||
StringGrammar, '%(delim)s[a-z]*'),
|
MatchGrammar0, '%(delim)s[a-z]*'),
|
||||||
RegionRule('perl.match', 'm(?P<delim>#)', MatchGrammar2, '#[a-z]*'),
|
RegionRule('perl.match', 'm(?P<delim>#)', MatchGrammar2, '#[a-z]*'),
|
||||||
|
|
||||||
# match regexes; paired delimiters
|
# match regexes; paired delimiters
|
||||||
#RegionRule('perl.replace', r's *(?P<delim>\()', MatchGrammar3,
|
|
||||||
# r'\) *\(', MatchGrammar3, r'\)[a-z]*'),
|
|
||||||
#RegionRule('perl.replace', r's *(?P<delim>\[)', MatchGrammar4,
|
|
||||||
# r'\] *\[', MatchGrammar4, r'\][a-z]*'),
|
|
||||||
#RegionRule('perl.replace', r's *(?P<delim>\{)', MatchGrammar5,
|
|
||||||
# r'\} *\{', MatchGrammar5, r'\}[a-z]*'),
|
|
||||||
#RegionRule('perl.replace', r's *(?P<delim>\<)', MatchGrammar6,
|
|
||||||
# r'\> *\<', MatchGrammar6, r'\>[a-z]*'),
|
|
||||||
RegionRule('perl.replace', r's *(?P<delim>\()', MatchGrammar3,
|
RegionRule('perl.replace', r's *(?P<delim>\()', MatchGrammar3,
|
||||||
r'\)', WhitespaceGrammar, '\(', MatchGrammar3, r'\)[a-z]*'),
|
r'\)', WhitespaceGrammar, '\(', MatchGrammar3, r'\)[a-z]*'),
|
||||||
RegionRule('perl.replace', r's *(?P<delim>\[)', MatchGrammar4,
|
RegionRule('perl.replace', r's *(?P<delim>\[)', MatchGrammar4,
|
||||||
|
@ -177,8 +196,8 @@ class PerlGrammar(Grammar):
|
||||||
RegionRule('perl.replace', 's *(?P<delim>/)', MatchGrammar1,
|
RegionRule('perl.replace', 's *(?P<delim>/)', MatchGrammar1,
|
||||||
'/', MatchGrammar1, '/[a-z]*'),
|
'/', MatchGrammar1, '/[a-z]*'),
|
||||||
RegionRule('perl.replace', 's *(?P<delim>[^ a-zA-Z0-9_])',
|
RegionRule('perl.replace', 's *(?P<delim>[^ a-zA-Z0-9_])',
|
||||||
StringGrammar, '%(delim)s',
|
MatchGrammar0, '%(delim)s',
|
||||||
StringGrammar, '%(delim)s[a-z]*'),
|
MatchGrammar0, '%(delim)s[a-z]*'),
|
||||||
RegionRule('perl.replace', 's(?P<delim>#)',
|
RegionRule('perl.replace', 's(?P<delim>#)',
|
||||||
MatchGrammar2, '#', MatchGrammar2, '#[a-z]*'),
|
MatchGrammar2, '#', MatchGrammar2, '#[a-z]*'),
|
||||||
|
|
||||||
|
@ -195,6 +214,7 @@ class PerlGrammar(Grammar):
|
||||||
PatternRule('perl.package', "(?<=package )" + word2),
|
PatternRule('perl.package', "(?<=package )" + word2),
|
||||||
PatternRule('perl.sub', "(?<=sub )" + word2),
|
PatternRule('perl.sub', "(?<=sub )" + word2),
|
||||||
PatternRule('perl.use', "(?<=use )" + word2),
|
PatternRule('perl.use', "(?<=use )" + word2),
|
||||||
|
PatternRule('perl.use', "(?<=no )" + word2),
|
||||||
PatternRule('perl.require', "(?<=require )" + word2),
|
PatternRule('perl.require', "(?<=require )" + word2),
|
||||||
PatternRule('perl.label', word1 + ':(?!:)'),
|
PatternRule('perl.label', word1 + ':(?!:)'),
|
||||||
PatternRule('perl.function', r"&\$*" + word2),
|
PatternRule('perl.function', r"&\$*" + word2),
|
||||||
|
@ -207,8 +227,8 @@ class PerlGrammar(Grammar):
|
||||||
RegionRule('perl.quoted', r'q[rqx] *(?P<delim>\[)', QuotedGrammar4, r'\]'),
|
RegionRule('perl.quoted', r'q[rqx] *(?P<delim>\[)', QuotedGrammar4, r'\]'),
|
||||||
RegionRule('perl.quoted', "q[rqx] *(?P<delim>')", Grammar, "'"),
|
RegionRule('perl.quoted', "q[rqx] *(?P<delim>')", Grammar, "'"),
|
||||||
RegionRule('perl.quoted', 'q[rqx] *(?P<delim>[^ a-zA-Z0-9#])',
|
RegionRule('perl.quoted', 'q[rqx] *(?P<delim>[^ a-zA-Z0-9#])',
|
||||||
StringGrammar, '%(delim)s'),
|
MatchGrammar0, '%(delim)s'),
|
||||||
RegionRule('perl.quoted', 'q[rqx](?P<delim>#)', StringGrammar, '#'),
|
RegionRule('perl.quoted', 'q[rqx](?P<delim>#)', MatchGrammar0, '#'),
|
||||||
|
|
||||||
# quote operator: q() and qw() do not interpolate
|
# quote operator: q() and qw() do not interpolate
|
||||||
RegionRule('perl.quoted', r'qw? *\(', QuotedWords, r'\)'),
|
RegionRule('perl.quoted', r'qw? *\(', QuotedWords, r'\)'),
|
||||||
|
@ -222,7 +242,7 @@ class PerlGrammar(Grammar):
|
||||||
PatternRule('perl.function', word2 + r"(?= *\()"),
|
PatternRule('perl.function', word2 + r"(?= *\()"),
|
||||||
PatternRule('perl.class', word2 + "(?=->)"),
|
PatternRule('perl.class', word2 + "(?=->)"),
|
||||||
|
|
||||||
PatternRule('perl.glob', r'(?:(?<=[^a-zA-Z0-9_])|(?<=^)) *\*[^ ]+'),
|
PatternRule('perl.glob', r'(?:(?<=[^a-zA-Z0-9_])|(?<=^)) *\*' + word2),
|
||||||
|
|
||||||
# some basic stuff
|
# some basic stuff
|
||||||
PatternRule('delimiter', r"::|->|=>|(?<!:):(?!=:)|[,;=\?(){}\[\]\(\)]"),
|
PatternRule('delimiter', r"::|->|=>|(?<!:):(?!=:)|[,;=\?(){}\[\]\(\)]"),
|
||||||
|
@ -781,6 +801,7 @@ class Perl(Fundamental):
|
||||||
# match regex
|
# match regex
|
||||||
'match.start': ('cyan', 'default', 'bold'),
|
'match.start': ('cyan', 'default', 'bold'),
|
||||||
'match.end': ('cyan', 'default', 'bold'),
|
'match.end': ('cyan', 'default', 'bold'),
|
||||||
|
'match.data': ('cyan', 'default', 'bold'),
|
||||||
'match.null': ('cyan', 'default', 'bold'),
|
'match.null': ('cyan', 'default', 'bold'),
|
||||||
|
|
||||||
# replace regex
|
# replace regex
|
||||||
|
@ -788,6 +809,7 @@ class Perl(Fundamental):
|
||||||
'replace.middle0': ('cyan', 'default', 'bold'),
|
'replace.middle0': ('cyan', 'default', 'bold'),
|
||||||
'replace.middle1': ('cyan', 'default', 'bold'),
|
'replace.middle1': ('cyan', 'default', 'bold'),
|
||||||
'replace.end': ('cyan', 'default', 'bold'),
|
'replace.end': ('cyan', 'default', 'bold'),
|
||||||
|
'replace.data': ('cyan', 'default', 'bold'),
|
||||||
'replace.null': ('cyan', 'default', 'bold'),
|
'replace.null': ('cyan', 'default', 'bold'),
|
||||||
'replace.escaped': ('magenta', 'default', 'bold'),
|
'replace.escaped': ('magenta', 'default', 'bold'),
|
||||||
'replace.deref': ('yellow', 'default', 'bold'),
|
'replace.deref': ('yellow', 'default', 'bold'),
|
||||||
|
@ -801,6 +823,9 @@ class Perl(Fundamental):
|
||||||
'translate.middle0': ('magenta', 'default', 'bold'),
|
'translate.middle0': ('magenta', 'default', 'bold'),
|
||||||
'translate.end': ('magenta', 'default', 'bold'),
|
'translate.end': ('magenta', 'default', 'bold'),
|
||||||
'translate.null': ('magenta', 'default', 'bold'),
|
'translate.null': ('magenta', 'default', 'bold'),
|
||||||
|
|
||||||
|
# xyz
|
||||||
|
'perl.glob': ('magenta', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
config = {}
|
config = {}
|
||||||
lconfig = {'perl.libs': []}
|
lconfig = {'perl.libs': []}
|
||||||
|
|
Loading…
Reference in New Issue