diff --git a/IDEAS b/IDEAS index 5f38283..3131e0e 100644 --- a/IDEAS +++ b/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: Either give buffers direct access to the application object, or make the diff --git a/mode/xml.py b/mode/xml.py index b0e3738..7b69903 100644 --- a/mode/xml.py +++ b/mode/xml.py @@ -18,11 +18,15 @@ class CommentGrammar(Grammar): rules = [PatternRule(r'data', r'(?:[^-]|-(?!-)|--(?!>))+')] class MetadataGrammar(Grammar): rules = [PatternRule(r'data', r'(?:[^?]|\?(?!>))+')] +class DoctypeGrammar(Grammar): + rules = [PatternRule(r'data', r'[^>]+')] class TagGrammar(Grammar): rules = [ PatternRule(r'attrname', r'[a-zA-Z_][a-zA-Z0-9_]+(?==)'), 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'delimiter', r'[:/=]'), RegionRule(r'string', r'"', StringGrammar1, r'"'), @@ -41,9 +45,11 @@ class XMLGrammar(Grammar): PatternMatchRule('x', r'(<)(/)([a-zA-Z_][a-zA-Z0-9_]*)(>)', 'xml.tag.start', 'xml.tag.delimiter', 'xml.tag.name', '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''), - RegionRule(r'xml.metadata', r'<\?', MetadataGrammar, r'\?>'), + #RegionRule(r'xml.metadata', r'<\?', MetadataGrammar, r'\?>'), + #RegionRule(r'xml.doctype', ''), RegionRule(r'xml.cdata', r''), ] @@ -84,20 +90,28 @@ class XmlCreateCdata(method.Method): class XML(mode.Fundamental): name = 'XML' extensions = ['.xml', '.xml.in', '.xsl', '.xsd'] + detection = ['?xml'] grammar = XMLGrammar colors = { - 'xml.metadata.start': ('magenta', 'default', 'bold'), - 'xml.metadata.data': ('magenta', 'default', 'bold'), - 'xml.metadata.end': ('magenta', 'default', 'bold'), - 'xml.tag.start': ('default', 'default', 'bold'), - 'xml.tag.namespace': ('magenta', 'default', 'bold'), - 'xml.tag.name': ('blue', 'default', 'bold'), - 'xml.tag.attrname': ('cyan', 'default', 'bold'), - 'xml.tag.end': ('default', 'default', 'bold'), - 'xml.entity': ('magenta', 'default', 'bold'), - 'xml.cdata.start': ('magenta', 'default', 'bold'), - 'xml.cdata.data': ('green', 'default', 'bold'), - 'xml.cdata.end': ('magenta', 'default', 'bold'), + #'xml.metadata.start': ('magenta', 'default', 'bold'), + #'xml.metadata.data': ('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.namespace': ('magenta', 'default', 'bold'), + 'xml.tag.name': ('blue', 'default', 'bold'), + 'xml.tag.attrname': ('cyan', 'default', 'bold'), + 'xml.tag.end': ('default', 'default', 'bold'), + 'xml.entity': ('magenta', 'default', 'bold'), + 'xml.cdata.start': ('magenta', 'default', 'bold'), + 'xml.cdata.data': ('green', 'default', 'bold'), + 'xml.cdata.end': ('magenta', 'default', 'bold'), } actions = [XmlValidate, XmlCreateTag, XmlCreateComment, XmlCreateCdata] _bindings = { diff --git a/window.py b/window.py index b48f381..8c6515b 100644 --- a/window.py +++ b/window.py @@ -64,7 +64,7 @@ class Window(object): mode_name = regex.auto_mode_emacs.search(firstline).group(1) elif regex.auto_mode_vi.search(firstline): mode_name = regex.auto_mode_vi.search(firstline).group(1) - elif firstline.startswith('#!'): + else: line = b.lines[0] for word in a.mode_detection: if word in line: