Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (55 sloc) 1.94 KB
;; Html, xml
;; Time-stamp: "2009-10-17 19:03:20 anton"
(add-to-list 'auto-mode-alist
(cons (concat "\\." (regexp-opt '("html" "xhtml" "xml" "xsd" "sch" "rng" "xslt" "svg" "rss") t) "\\'")
(when (boundp 'magic-mode-alist)
(setq magic-mode-alist
(cons '("<?xml " . nxml-mode)
(fset 'xml-mode 'nxml-mode)
(fset 'html-mode 'nxml-mode)
(defun aj-nxml-mode-hook()
(setq truncate-lines t))
(add-hook 'nxml-mode-hook 'aj-nxml-mode-hook)
(defun insert-xhtml-template ()
"inserts xhtml template"
(goto-line 1)
"<?xml version=\"1.0\" encoding=\"utf-8\"?>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
<html xmlns=\"\">
<!-- Time-stamp: \"" (format-time-string "%c") "\" -->
<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />
<meta name=\"author\" content=\""
"\" />
(indent-region (region-beginning) (region-end) nil)
(search-forward "title>"))
;; Snatched from Benjamin Ferrari
(defun aj-nxml-pretty (begin end)
"Pretty format XML markup in region. You need to have nxml-mode installed to do
this. The function inserts linebreaks to separate tags that have
nothing but whitespace between them. It then indents the markup
by using nxml's indentation rules."
(interactive "r")
(goto-char begin)
(while (search-forward-regexp "\>[ \\t]*\<" nil t)
(backward-char) (insert "\n"))
(indent-region begin end))
(message "Done!"))
(provide 'aj-html)