parent
fa6ac4b06e
commit
75a31bd921
4
IDEAS
4
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
|
Try to create some more toggles on the indentation package, to make it at least
|
||||||
a little bit configurable.
|
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:
|
2009/03/27:
|
||||||
|
|
||||||
1. Create a Method attribute meaning should-appear-in-help-buffers. Use this to
|
1. Create a Method attribute meaning should-appear-in-help-buffers. Use this to
|
||||||
|
|
52
mode/diff.py
52
mode/diff.py
|
@ -1,14 +1,14 @@
|
||||||
from mode import Fundamental
|
from mode import Fundamental
|
||||||
from lex import Grammar, PatternRule
|
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
||||||
|
|
||||||
class DiffGrammar(Grammar):
|
class DiffGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(name=r'left', pattern=r"^\-.*\n$"),
|
PatternRule('diff.left', r"^\-.*\n$"),
|
||||||
PatternRule(name=r'right', pattern=r"^\+.*\n$"),
|
PatternRule('diff.right', r"^\+.*\n$"),
|
||||||
PatternRule(name=r'metadata', pattern=r'^[A-Za-z].*\n$'),
|
PatternRule('diff.metadata', r'^[A-Za-z].*\n$'),
|
||||||
PatternRule(name=r'seperator', pattern=r'^={67}\n$'),
|
PatternRule('diff.seperator', r'^={67}\n$'),
|
||||||
PatternRule(name=r'location', pattern=r"^@@ [-+0-9a-z, ]* @@\n$"),
|
PatternRule('diff.location', r"^@@ [-+0-9a-z, ]* @@\n$"),
|
||||||
PatternRule(name=r'common', pattern=r"^.*\n$"),
|
PatternRule('diff.common', r"^.*\n$"),
|
||||||
]
|
]
|
||||||
|
|
||||||
class Diff(Fundamental):
|
class Diff(Fundamental):
|
||||||
|
@ -16,11 +16,37 @@ class Diff(Fundamental):
|
||||||
extensions = ['.patch', '.diff']
|
extensions = ['.patch', '.diff']
|
||||||
grammar = DiffGrammar()
|
grammar = DiffGrammar()
|
||||||
colors = {
|
colors = {
|
||||||
'left': ('red', 'default', 'bold'),
|
'diff.left': ('red', 'default', 'bold'),
|
||||||
'right': ('blue', 'default', 'bold'),
|
'diff.right': ('blue', 'default', 'bold'),
|
||||||
'seperator': ('magenta', 'default', 'bold'),
|
'diff.seperator': ('magenta', 'default', 'bold'),
|
||||||
'metadata': ('magenta', 'default', 'bold'),
|
'diff.metadata': ('magenta', 'default', 'bold'),
|
||||||
'location': ('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)
|
||||||
|
|
Loading…
Reference in New Issue