parent
b134fed9e9
commit
f6c0e57e11
8
lex.py
8
lex.py
|
@ -128,8 +128,9 @@ class NocasePatternRule(PatternRule):
|
|||
reflags = re.IGNORECASE
|
||||
|
||||
class FakeWindow(object):
|
||||
def __init__(self, app):
|
||||
def __init__(self, app, b):
|
||||
self.application = app
|
||||
self.buffer = b
|
||||
class OverrideError(Exception):
|
||||
pass
|
||||
class OverridePatternRule(PatternRule):
|
||||
|
@ -139,13 +140,16 @@ class OverridePatternRule(PatternRule):
|
|||
if lexer.action == 'lex':
|
||||
a = lexer.mode.window.application
|
||||
try:
|
||||
b = lexer.mode.window.buffer
|
||||
modecls = a.modes[d['mode']]
|
||||
mode = modecls(FakeWindow(lexer.mode.window.application))
|
||||
mode = modecls(FakeWindow(lexer.mode.window.application, b))
|
||||
if hasattr(mode, 'grammar') and hasattr(mode, 'colors'):
|
||||
lexer.mode.gstack['%s' % d['token']] = mode
|
||||
else:
|
||||
raise OverrideError("argh: %r" % mode)
|
||||
except (KeyError, AttributeError, OverrideError):
|
||||
# uncomment raise to fix dynamic highlighting
|
||||
#raise
|
||||
pass
|
||||
yield self.make_token(lexer, m.group(0), self.name, parent, d)
|
||||
raise StopIteration
|
||||
|
|
Loading…
Reference in New Issue