diff --git a/mode/html.py b/mode/html.py index d1291ca..b498e3b 100644 --- a/mode/html.py +++ b/mode/html.py @@ -73,6 +73,7 @@ class HTML(mode.Fundamental): self.add_bindings('close-paren', (')',)) self.add_bindings('close-brace', ('}',)) self.add_bindings('close-bracket', (']',)) + self.add_bindings('xml-create-tag', ('M-t',)) self.add_action(HtmlViewPage()) self.add_action(HtmlCheckSpelling()) diff --git a/mode/xml.py b/mode/xml.py index 231c356..36b983f 100644 --- a/mode/xml.py +++ b/mode/xml.py @@ -24,6 +24,16 @@ class XmlValidate(method.shell.Exec): def _execute(self, w, **vargs): self._doit(w, w.buffer.path, 'xmlwf %(path)r', cmdname='xml-validate') +class XmlCreateTag(method.Method): + '''''' + args = [method.Argument('tagname', prompt="Tag Name: ", help="Create an open/close tag pair")] + def _execute(self, w, **vargs): + t = vargs['tagname'] + w.insert_string_at_cursor("<%s>" % t) + p = w.logical_cursor() + w.insert_string_at_cursor("" % t) + w.goto(p) + class XML(mode.Fundamental): modename = 'XML' extensions = ['.xml', '.xml.in'] @@ -38,6 +48,9 @@ class XML(mode.Fundamental): 'xml_tag.string.end': ('green', 'default', 'bold'), 'xml_tag.end': ('default', 'default', 'bold'), } - actions = [XmlValidate] + actions = [XmlValidate, XmlCreateTag] + def __init__(self, w): + mode.Fundamental.__init__(self, w) + self.add_bindings('xml-create-tag', ('M-t',)) install = XML.install