pmacs3/mode/ipython.py

25 lines
802 B
Python

from mode import Fundamental
from lex import Grammar, PatternRule, RegionRule
from mode.python import StringGrammar1, StringGrammar2, PythonGrammar
class IpythonGrammar(Grammar):
rules = [
PatternRule(r'comment', r'#.*$'),
RegionRule(r'string', r'"', StringGrammar2, r'"'),
RegionRule(r'string', r"'", StringGrammar1, r"'"),
RegionRule(r'ipython_input', r'^(?:>>>|-->)', PythonGrammar, '\n$'),
PatternRule(r'ipython_reserved', r'undef'),
]
class Ipython(Fundamental):
name = 'IPython'
grammar = IpythonGrammar()
colors = {
'ipython_input.start': ('red', 'default', 'bold'),
'ipython_reserved': ('magenta', 'default', 'bold'),
}
_bindings = {
'ipython-start': ('M-e',),
}
install = Ipython.install