]> code.delx.au - gnu-emacs/blobdiff - lisp/nxml/nxml-mode.el
Update copyright year to 2016
[gnu-emacs] / lisp / nxml / nxml-mode.el
index 6c5c85b2fcc879d1ece8b96a72502db962926ef9..324350f591c4098f1d42c2b6bb4447bcd7225a38 100644 (file)
@@ -1,6 +1,6 @@
 ;;; nxml-mode.el --- a new XML mode  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2003-2004, 2007-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2004, 2007-2016 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML
@@ -546,6 +546,7 @@ Many aspects this mode can be customized using
   (setq comment-end-skip "[ \t\r\n]*-->")
   (make-local-variable 'comment-line-break-function)
   (setq comment-line-break-function 'nxml-newline-and-indent)
+  (setq-local comment-quote-nested-function 'nxml-comment-quote-nested)
   (use-local-map nxml-mode-map)
   (save-excursion
     (save-restriction
@@ -1350,6 +1351,18 @@ of the inserted start-tag or nil if none was inserted."
                            start-tag-indent)))))
     inserted-start-tag-pos))
 
+(defun nxml-comment-quote-nested (_cs _ce unp)
+  "Quote nested comments in buffer.
+See `comment-quote-nested-function' for more information."
+  (goto-char (point-min))
+  (save-match-data
+    (while (re-search-forward "-[\\]*-" nil t)
+      (goto-char (match-beginning 0))
+      (forward-char 1)
+      (if unp
+         (delete-char 1)
+       (insert "\\")))))
+
 ;;; Indentation
 
 (defun nxml-indent-line ()