I use the Insert Close Tag command all the time when writing XML in TextMate. Unfortunately, this command is inherited from the HTML bundle, and that causes problems due to the differing semantics between HTML and XML. Specifically, HTML defines certain self-closing tags, such as <link>, but in XML these tags may have content and are not self-closing. As a result, the Insert Close Tag can break in XML mode. For example:
1. Create a new document 2. Switch to XML mode 3. Type <link> 4. Type some text 5. Call the Insert Close Tag command by typing Command + Option + .
Expected behavior: TextMate inserts the closing </link> tag automatically Actual behavior: TextMate beeps at you
Trevor
On 16. Apr 2007, at 03:27, Trevor Harmon wrote:
I use the Insert Close Tag command all the time when writing XML [...]
Expected behavior: TextMate inserts the closing </link> tag automatically Actual behavior: TextMate beeps at you
Well, it is expected to insert the closing *HTML* tag, given its placement in the HTML bundle ;)
But I updated the command to read TM_HTML_EMPTY_TAGS from the environment. As this is unset for XML, it will now close <link> and other tags which have an empty content model in HTML.
I also updated the Insert Open/Close Tag (⌃<) to check this variable, so now you can write link⌃< in XML and get ‘<link>‸</ link>’ (instead of ‘<link ‸>’).