fnwiya's quine

自分自身を出力するブログ

emacsでxmlを編集するときの設定

xmlを書いていると開始タグと閉じタグがごちゃごちゃしてきて対応関係がわからなくなったりしますが
こちらの設定を行えば</で閉じタグを補完してくれるので
非常に便利です。
カラーはお好みでどうぞ。

(use-package nxml-mode
  :mode
  (("\.xml$" . nxml-mode)
   ("\.xsl$" . nxml-mode)
   ("\.xhtml$" . nxml-mode)
   ("\.page$" . nxml-mode))
  :config
  (setq nxml-child-indent 2)                  ; タグのインデント幅
  (setq nxml-attribute-indent 2)              ; 属性のインデント幅
  (setq indent-tabs-mode nil)
  (setq nxml-slash-auto-complete-flag t)      ; </の入力で閉じタグを補完する
  (setq tab-width 2)


  (custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(nxml-comment-content-face ((t (:foreground "yellow4"))))
 '(nxml-comment-delimiter-face ((t (:foreground "yellow4"))))
 '(nxml-delimited-data-face ((t (:foreground "lime green"))))
 '(nxml-delimiter-face ((t (:foreground "grey"))))
 '(nxml-element-local-name-face ((t (:inherit nxml-name-face :foreground "medium turquoise"))))
 '(nxml-name-face ((t (:foreground "rosy brown"))))
 '(nxml-tag-slash-face ((t (:inherit nxml-name-face :foreground "grey")))))
)