expand mode-detection beyond #! to <?xml>
--HG-- branch : pmacs2
This commit is contained in:
parent
f274cdd973
commit
a098646d42
5
IDEAS
5
IDEAS
|
@ -1,3 +1,8 @@
|
||||||
|
2009/07/11:
|
||||||
|
|
||||||
|
Redo mode detection so that it uses regexes not words. Then fix all the modes
|
||||||
|
that want #! detection.
|
||||||
|
|
||||||
2009/05/05:
|
2009/05/05:
|
||||||
|
|
||||||
Either give buffers direct access to the application object, or make the
|
Either give buffers direct access to the application object, or make the
|
||||||
|
|
24
mode/xml.py
24
mode/xml.py
|
@ -18,11 +18,15 @@ class CommentGrammar(Grammar):
|
||||||
rules = [PatternRule(r'data', r'(?:[^-]|-(?!-)|--(?!>))+')]
|
rules = [PatternRule(r'data', r'(?:[^-]|-(?!-)|--(?!>))+')]
|
||||||
class MetadataGrammar(Grammar):
|
class MetadataGrammar(Grammar):
|
||||||
rules = [PatternRule(r'data', r'(?:[^?]|\?(?!>))+')]
|
rules = [PatternRule(r'data', r'(?:[^?]|\?(?!>))+')]
|
||||||
|
class DoctypeGrammar(Grammar):
|
||||||
|
rules = [PatternRule(r'data', r'[^>]+')]
|
||||||
|
|
||||||
class TagGrammar(Grammar):
|
class TagGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(r'attrname', r'[a-zA-Z_][a-zA-Z0-9_]+(?==)'),
|
PatternRule(r'attrname', r'[a-zA-Z_][a-zA-Z0-9_]+(?==)'),
|
||||||
PatternRule(r'namespace', r'[a-zA-Z_]+(?=:)'),
|
PatternRule(r'namespace', r'[a-zA-Z_]+(?=:)'),
|
||||||
|
PatternRule(r'meta', r'\?xml'),
|
||||||
|
PatternRule(r'doctype', r'!DOCTYPE'),
|
||||||
PatternRule(r'name', r'[a-zA-Z_][a-zA-Z0-9_]*'),
|
PatternRule(r'name', r'[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||||
PatternRule(r'delimiter', r'[:/=]'),
|
PatternRule(r'delimiter', r'[:/=]'),
|
||||||
RegionRule(r'string', r'"', StringGrammar1, r'"'),
|
RegionRule(r'string', r'"', StringGrammar1, r'"'),
|
||||||
|
@ -41,9 +45,11 @@ class XMLGrammar(Grammar):
|
||||||
PatternMatchRule('x', r'(<)(/)([a-zA-Z_][a-zA-Z0-9_]*)(>)',
|
PatternMatchRule('x', r'(<)(/)([a-zA-Z_][a-zA-Z0-9_]*)(>)',
|
||||||
'xml.tag.start', 'xml.tag.delimiter', 'xml.tag.name',
|
'xml.tag.start', 'xml.tag.delimiter', 'xml.tag.name',
|
||||||
'xml.tag.end'),
|
'xml.tag.end'),
|
||||||
RegionRule(r'xml.tag', r'<(?![\?!])', TagGrammar, r'/?>'),
|
#RegionRule(r'xml.tag', r'<(?![\?!])', TagGrammar, r'/?>'),
|
||||||
|
RegionRule(r'xml.tag', r'<', TagGrammar, r'/?>'),
|
||||||
RegionRule(r'comment', r'<!--', CommentGrammar, r'-->'),
|
RegionRule(r'comment', r'<!--', CommentGrammar, r'-->'),
|
||||||
RegionRule(r'xml.metadata', r'<\?', MetadataGrammar, r'\?>'),
|
#RegionRule(r'xml.metadata', r'<\?', MetadataGrammar, r'\?>'),
|
||||||
|
#RegionRule(r'xml.doctype', '<!', DoctypeGrammar, '>'),
|
||||||
RegionRule(r'xml.cdata', r'<!\[CDATA\[', CDataGrammar, r'\]\]>'),
|
RegionRule(r'xml.cdata', r'<!\[CDATA\[', CDataGrammar, r'\]\]>'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -84,11 +90,19 @@ class XmlCreateCdata(method.Method):
|
||||||
class XML(mode.Fundamental):
|
class XML(mode.Fundamental):
|
||||||
name = 'XML'
|
name = 'XML'
|
||||||
extensions = ['.xml', '.xml.in', '.xsl', '.xsd']
|
extensions = ['.xml', '.xml.in', '.xsl', '.xsd']
|
||||||
|
detection = ['?xml']
|
||||||
grammar = XMLGrammar
|
grammar = XMLGrammar
|
||||||
colors = {
|
colors = {
|
||||||
'xml.metadata.start': ('magenta', 'default', 'bold'),
|
#'xml.metadata.start': ('magenta', 'default', 'bold'),
|
||||||
'xml.metadata.data': ('magenta', 'default', 'bold'),
|
#'xml.metadata.data': ('magenta', 'default', 'bold'),
|
||||||
'xml.metadata.end': ('magenta', 'default', 'bold'),
|
#'xml.metadata.end': ('magenta', 'default', 'bold'),
|
||||||
|
#'xml.doctype.start': ('magenta', 'default', 'bold'),
|
||||||
|
#'xml.doctype.data': ('magenta', 'default', 'bold'),
|
||||||
|
#'xml.doctype.end': ('magenta', 'default', 'bold'),
|
||||||
|
|
||||||
|
'xml.tag.meta': ('magenta', 'default', 'bold'),
|
||||||
|
'xml.tag.doctype': ('magenta', 'default', 'bold'),
|
||||||
|
|
||||||
'xml.tag.start': ('default', 'default', 'bold'),
|
'xml.tag.start': ('default', 'default', 'bold'),
|
||||||
'xml.tag.namespace': ('magenta', 'default', 'bold'),
|
'xml.tag.namespace': ('magenta', 'default', 'bold'),
|
||||||
'xml.tag.name': ('blue', 'default', 'bold'),
|
'xml.tag.name': ('blue', 'default', 'bold'),
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Window(object):
|
||||||
mode_name = regex.auto_mode_emacs.search(firstline).group(1)
|
mode_name = regex.auto_mode_emacs.search(firstline).group(1)
|
||||||
elif regex.auto_mode_vi.search(firstline):
|
elif regex.auto_mode_vi.search(firstline):
|
||||||
mode_name = regex.auto_mode_vi.search(firstline).group(1)
|
mode_name = regex.auto_mode_vi.search(firstline).group(1)
|
||||||
elif firstline.startswith('#!'):
|
else:
|
||||||
line = b.lines[0]
|
line = b.lines[0]
|
||||||
for word in a.mode_detection:
|
for word in a.mode_detection:
|
||||||
if word in line:
|
if word in line:
|
||||||
|
|
Loading…
Reference in New Issue