X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/08b3caa982199bd7939d9d6877203ada5d0083b5..f2cdb04ac04fb8f9f92bce11df6e4a020720208b:/lisp/nxml/nxml-mode.el diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el index 49dcaecaab..5eb9840a4c 100644 --- a/lisp/nxml/nxml-mode.el +++ b/lisp/nxml/nxml-mode.el @@ -1,6 +1,6 @@ ;;; nxml-mode.el --- a new XML mode -;; Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc. +;; Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: James Clark ;; Keywords: XML @@ -45,13 +45,11 @@ (defgroup nxml nil "New XML editing mode." - :group 'languages - :group 'wp) + :group 'languages) (defgroup nxml-faces nil "Faces for XML syntax highlighting." - :group 'nxml - :group 'font-lock-faces) + :group 'nxml) (defcustom nxml-char-ref-display-glyph-flag t "*Non-nil means display glyph following character reference. @@ -882,16 +880,17 @@ Called with `font-lock-beg' and `font-lock-end' dynamically bound." (defun nxml-extend-after-change-region (start end pre-change-length) (unless nxml-degraded (setq nxml-last-fontify-end nil) - - (nxml-with-degradation-on-error 'nxml-extend-after-change-region - (save-excursion - (save-restriction - (widen) - (save-match-data - (nxml-with-invisible-motion - (nxml-with-unmodifying-text-property-changes - (nxml-extend-after-change-region1 - start end pre-change-length))))))))) + (let ((region (nxml-with-degradation-on-error + 'nxml-extend-after-change-region + (save-excursion + (save-restriction + (widen) + (save-match-data + (nxml-with-invisible-motion + (nxml-with-unmodifying-text-property-changes + (nxml-extend-after-change-region1 + start end pre-change-length))))))))) + (if (consp region) region)))) (defun nxml-extend-after-change-region1 (start end pre-change-length) (let* ((region (nxml-after-change1 start end pre-change-length)) @@ -1254,29 +1253,31 @@ No extra whitespace is inserted." (defun nxml-balanced-close-start-tag (block-or-inline) (let ((token-end (nxml-token-before)) - (pos (1+ (point)))) + (pos (1+ (point))) + (token-start xmltok-start)) (unless (or (eq xmltok-type 'partial-start-tag) (and (memq xmltok-type '(start-tag empty-element partial-empty-element)) (>= token-end pos))) (error "Not in a start-tag")) + ;; Note that this insertion changes xmltok-start. (insert ">") (if (eq block-or-inline 'inline) (goto-char pos) - (goto-char xmltok-start) + (goto-char token-start) (back-to-indentation) - (if (= (point) xmltok-start) + (if (= (point) token-start) (let ((indent (current-column))) - (goto-char pos) - (insert "\n") - (indent-line-to indent) - (goto-char pos) - (insert "\n") - (indent-line-to (+ nxml-child-indent indent))) + (goto-char pos) + (insert "\n") + (indent-line-to indent) + (goto-char pos) + (insert "\n") + (indent-line-to (+ nxml-child-indent indent))) (goto-char pos))))) (defun nxml-finish-element () @@ -1370,7 +1371,8 @@ of the inserted start-tag or nil if none was inserted." "Indent current line as XML." (let ((indent (nxml-compute-indent)) (from-end (- (point-max) (point)))) - (when indent + (when (and indent + (/= indent (current-indentation))) (beginning-of-line) (let ((bol (point))) (skip-chars-forward " \t") @@ -2651,6 +2653,9 @@ With a prefix argument, inserts the character directly." (put 'entity-ref 'nxml-friendly-name "entity reference") (put 'char-ref 'nxml-friendly-name "character reference") +;;;###autoload +(defalias 'xml-mode 'nxml-mode) + (provide 'nxml-mode) ;; arch-tag: 8603bc5f-1ef9-4021-b223-322fb2ca708e