forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-nxml.el
44 lines (35 loc) · 1.62 KB
/
init-nxml.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(add-to-list 'auto-mode-alist
(cons (concat "\\." (regexp-opt '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss") t) "\\'")
'nxml-mode))
(setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
(fset 'html-mode 'nxml-mode)
(fset 'xml-mode 'nxml-mode)
(add-hook 'nxml-mode-hook (lambda ()
(set (make-local-variable 'ido-use-filename-at-point) nil)))
(setq nxml-slash-auto-complete-flag t)
;; There are newer schema files here: http://syntax.whattf.org/relaxng/
(eval-after-load 'rng-loc
'(progn
(require 'whattf-dt)
(push (expand-file-name "schemas.xml" (directory-of-library "whattf-dt"))
rng-schema-locating-files)))
;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
(defun pp-xml-region (begin end)
"Pretty format XML markup in region. 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")
(save-excursion
(nxml-mode)
(goto-char begin)
(while (search-forward-regexp "\>[ \\t]*\<" nil t)
(backward-char) (insert "\n"))
(indent-region begin end)))
;;----------------------------------------------------------------------------
;; Integration with tidy for html + xml
;;----------------------------------------------------------------------------
(add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
(add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
(add-auto-mode 'html-mode "\\.(jsp|tmpl)$")
(provide 'init-nxml)