diff --git a/IDEAS b/IDEAS index 4b30c5c..b731e59 100644 --- a/IDEAS +++ b/IDEAS @@ -10,6 +10,10 @@ strategy. If not, then try to at least generalize it more. Try to create some more toggles on the indentation package, to make it at least a little bit configurable. +Move some "global methods" which use particular modes into those modes' files. +Also, try to combine some modes that are always intended to be used together +(for instace, python/ipython, perl/iperl, */*mini, etc) + 2009/03/27: 1. Create a Method attribute meaning should-appear-in-help-buffers. Use this to diff --git a/mode/diff.py b/mode/diff.py index c4d69d8..733d477 100644 --- a/mode/diff.py +++ b/mode/diff.py @@ -1,14 +1,14 @@ from mode import Fundamental -from lex import Grammar, PatternRule +from lex import Grammar, PatternRule, RegionRule, PatternMatchRule class DiffGrammar(Grammar): rules = [ - PatternRule(name=r'left', pattern=r"^\-.*\n$"), - PatternRule(name=r'right', pattern=r"^\+.*\n$"), - PatternRule(name=r'metadata', pattern=r'^[A-Za-z].*\n$'), - PatternRule(name=r'seperator', pattern=r'^={67}\n$'), - PatternRule(name=r'location', pattern=r"^@@ [-+0-9a-z, ]* @@\n$"), - PatternRule(name=r'common', pattern=r"^.*\n$"), + PatternRule('diff.left', r"^\-.*\n$"), + PatternRule('diff.right', r"^\+.*\n$"), + PatternRule('diff.metadata', r'^[A-Za-z].*\n$'), + PatternRule('diff.seperator', r'^={67}\n$'), + PatternRule('diff.location', r"^@@ [-+0-9a-z, ]* @@\n$"), + PatternRule('diff.common', r"^.*\n$"), ] class Diff(Fundamental): @@ -16,11 +16,37 @@ class Diff(Fundamental): extensions = ['.patch', '.diff'] grammar = DiffGrammar() colors = { - 'left': ('red', 'default', 'bold'), - 'right': ('blue', 'default', 'bold'), - 'seperator': ('magenta', 'default', 'bold'), - 'metadata': ('magenta', 'default', 'bold'), - 'location': ('magenta', 'default', 'bold'), + 'diff.left': ('red', 'default', 'bold'), + 'diff.right': ('blue', 'default', 'bold'), + 'diff.seperator': ('magenta', 'default', 'bold'), + 'diff.metadata': ('magenta', 'default', 'bold'), + 'diff.location': ('magenta', 'default', 'bold'), } -install = Diff.install +class Diff3Line(Grammar): + rules = [PatternMatchRule('x', r'^( )(.*)\n$', 'pre', 'data')] +class Diff3Grammar(Grammar): + rules = [ + PatternRule('diff.seperator', r'^====\n$'), + RegionRule('diff.part1', r"^1:\d+,\d+[a-z]\n$", Diff3Line, '^(?=[^ ])'), + RegionRule('diff.part2', r"^2:\d+,\d+[a-z]\n$", Diff3Line, '^(?=[^ ])'), + RegionRule('diff.part3', r"^3:\d+,\d+[a-z]\n$", Diff3Line, '^(?=[^ ])'), + PatternRule('diff.common', r"^.*\n$"), + ] + +class Diff3(Fundamental): + name = 'diff3' + extensions = ['.diff3'] + grammar = Diff3Grammar() + colors = { + 'diff.part1.start': ('yellow', 'default', 'bold'), + 'diff.part1.pre': ('red', 'red', 'bold'), + 'diff.part2.start': ('yellow', 'default', 'bold'), + 'diff.part2.pre': ('green', 'green', 'bold'), + 'diff.part3.start': ('yellow', 'default', 'bold'), + 'diff.part3.pre': ('blue', 'blue', 'bold'), + } + +def install(*args, **kwargs): + Diff.install(*args, **kwargs) + Diff3.install(*args, **kwargs)