improve indentation, git log-parsing, and scala-mode

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2011-08-16 11:23:41 -04:00
commit 5ba91e2ab1
3 changed files with 11 additions and 10 deletions

View File

@ -30,8 +30,9 @@ class StringGrammar(Grammar):
class SubTypeGrammar(Grammar): pass
SubTypeGrammar.rules = [
RegionRule('sub', r'\[', SubTypeGrammar, r'\]'),
PatternRule('scala.type', '[a-zA-Z0-9_]+'),
PatternRule('scala.type', '(?:[a-zA-Z0-9_.]+| *=> *)+'),
PatternRule('spaces', ' +'),
PatternRule('scala.annotation', '@[a-zA-Z_][a-zA-Z0-9_]*'),
]
class ScalaGrammar(Grammar):
@ -40,18 +41,18 @@ class ScalaGrammar(Grammar):
RegionRule('scala.comment', r'/\*', NestedCommentGrammar, r'\*/'),
RegionRule('scala.script', r'#!.+$', ShGrammar, r'!#'),
PatternMatchRule('x', r'(?<!:)(:)([a-zA-Z0-9_]+)',
PatternMatchRule('x', r'(?<!:)(:)((?:[a-zA-Z0-9_.]+| *=> *)+)',
'delimiter', 'scala.type'),
PatternMatchRule('x', r'(?<!:)(:)( +)([a-zA-Z0-9_]+)',
PatternMatchRule('x', r'(?<!:)(:)( +)((?:[a-zA-Z0-9_.]+| *=> *)+)',
'delimiter', 'spaces', 'scala.type'),
#PatternMatchRule('x', r'(?<=[a-zA-Z0-9_ ])(:)([a-zA-Z0-9_]+)',
# 'delimiter', 'scala.type'),
#PatternMatchRule('x', r'(?<=[a-zA-Z0-9_ ])(:)( +)([a-zA-Z0-9_]+)',
# 'delimiter', 'spaces', 'scala.type'),
PatternMatchRule('x', r'(extends)( +)([a-zA-Z0-9_]+)',
PatternMatchRule('x', r'(extends)( +)([a-zA-Z0-9_.]+)',
'scala.reserved', 'spaces', 'scala.type'),
PatternMatchRule('x', r'(with)( +)([a-zA-Z0-9_]+)',
PatternMatchRule('x', r'(with)( +)([a-zA-Z0-9_.]+)',
'scala.reserved', 'spaces', 'scala.type'),
#PatternRule('delimiter', r'(?:;|{|}|\[|\]|\(|\)|,|\.|<(?![a-zA-Z_])|>|:|/|\+|-|\*|=)'),
@ -69,7 +70,7 @@ class ScalaGrammar(Grammar):
PatternRule('scala.object', '(?<=(?<![a-zA-Z0-9_])object )[a-zA-Z_][a-zA-Z0-9_]*'),
PatternRule('scala.trait', '(?<=(?<![a-zA-Z0-9_])trait )[a-zA-Z_][a-zA-Z0-9_]*'),
PatternRule('scala.pseudo', '(?:true|null|false)'),
PatternRule('scala.pseudo', '(?:true|null|false)(?!%s)' % word),
PatternRule('scala.reserved', '(?:yield|with|while|var|val|until|type|true|try|trait|throw|to|this|super|sealed|return|protected|private|package|override|object|null|new|match|lazy|import|implicit|if|forSome|for|finally|final|false|extends|else|do|def|class|catch|case|abstract)(?!%s)' % word),
@ -337,7 +338,7 @@ class Scala(Fundamental):
'scala.script.start': hi_red,
'scala.script.end': hi_red,
'scala.annotation': lo_green,
'scala.annotation': lo_orange,
'scala.pseudo': hi_magenta,
'scala.reserved': hi_cyan,

4
tab.py
View File

@ -473,9 +473,9 @@ class StackTabber2(Tabber):
# remove implicit continuation
if self.end_at_eof and i + start == end:
self._pop_while('continue', 'control')
self._pop_while('continue', 'control', 'pre-control')
elif self.end_at_tokens.get(name, {}).get(s):
self._pop_while('continue', 'control')
self._pop_while('continue', 'control', 'pre-control')
# add implicit continuation
top = self._peek()