fix spell-as-you-type

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2010-03-01 16:12:27 -05:00
parent 5b4319774d
commit 8b61ef8cf1
1 changed files with 10 additions and 4 deletions

View File

@ -15,9 +15,9 @@ class WordRule(PatternRule):
if m:
s = m.group(0)
if self._spelled_ok(s):
token = Token('word', self, lexer.y, lexer.x, s, None, parent, {})
token = Token('text.word', self, lexer.y, lexer.x, s, None, parent, {})
else:
token = Token('misspelled', self, lexer.y, lexer.x, s, None, parent, {})
token = Token('text.misspelled', self, lexer.y, lexer.x, s, None, parent, {})
token.color = lexer.get_color(token)
lexer.x += len(s)
yield token
@ -31,8 +31,8 @@ class TextGrammar(Grammar):
rules = [
ContinuedRule(),
WordRule(),
PatternRule(r'punct', r'[^a-zA-Z0-9_]'),
PatternRule(r'stuff', r'[a-zA-Z0-9_]+'),
PatternRule(r'text.punct', r'[^a-zA-Z0-9_]'),
PatternRule(r'text.stuff', r'[a-zA-Z0-9_]+'),
]
class TextWrapParagraph(method.WrapParagraph):
@ -85,5 +85,11 @@ class Text(Fundamental):
'text-insert-space': ('SPACE',),
'text-wrap-paragraph': ('M-q',),
}
colors = {
'text.punct': ('default', 'default'),
'text.stuff': ('default', 'default'),
'text.word': ('default', 'default'),
'text.misspelled': ('red', 'default'),
}
install = Text.install