Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make emacs always close html tags

Tags:

emacs

sgml

How can I make emacs always close a sgml-tag (C-c-C-t)?

For example div, h2 tags work fine but p or li do not. Basically I'm looking for a way of specifing that I'm always using xhtml when I insert a tag.

like image 404
vise Avatar asked Nov 24 '10 09:11

vise


1 Answers

You need to turn on sgml-xml-mode:

When non-nil, tag insertion functions will be XML-compliant.

sgml-mode attempts to guess whether your buffer is in XHTML (and so turn on sgml-xml-mode automatically) by looking at the doctype. See the function sgml-xml-guess. It's expecting to find the string "XHTML" somewhere in the DTD name.

If you can't get sgml-xml-guess to work, then you could turn on sgml-xml-mode explicitly. Perhaps like this:

(add-hook 'html-mode-hook #'(lambda nil (setq sgml-xml-mode t)))
like image 175
Gareth Rees Avatar answered Oct 06 '22 01:10

Gareth Rees