 
 	;; Continued comment.
 	(and (looking-at "\\*") (urweb-find-comment-indent))
+
+        (and (urweb-in-xml)
+             (let ((prev-indent (save-excursion
+                                  (previous-line 1)
+                                  (re-search-backward "^[^\n]" nil t)
+                                  (current-indentation))))
+               (cond
+                ((looking-at "</")
+                 (urweb-tag-matching-indent))
+                ((urweb-new-tags)
+                 (+ prev-indent 2))
+                (t
+                 prev-indent))))
 
 	;; Continued string ? (Added 890113 lbn)
 	(and (looking-at "\\\\")

        (cond
         ((looking-at "{")
          (if (> depth 0)
              (setq depth (- depth 1))
            (setq finished t)))
         ((looking-at "}")
          (setq depth (+ depth 1)))
         ((save-excursion (backward-char 1) (or (looking-at "=>") (looking-at "->")))
          nil)
         ((looking-at "<")

	  (1+ (current-column))
	nil))))

(defun urweb-new-tags ()
  "Decide if the previous line of XML introduced unclosed tags"
  (save-excursion
    (let ((start-pos (point))
          (depth 0)
          (done nil))
      (previous-line 1)
      (beginning-of-line)
      (while (and (not done) (search-forward "<" start-pos t))
        (if (looking-at "/")
          (if (search-forward ">" start-pos t)
              (when (> depth 0) (decf depth))
            (setq done t))
          (if (search-forward ">" start-pos t)
              (if (not (save-excursion (backward-char 2) (looking-at "/")))
                  (incf depth))
            (setq done t))))
      (and (not done) (> depth 0)))))

(defun urweb-tag-matching-indent ()
  "Seek back to a matching opener tag and get its line's indent"
  (save-excursion
    (let ((depth 0)
          (done nil))
      (while (and (not done) (search-backward ">" nil t))
        (if (save-excursion (backward-char 1) (looking-at "/"))
            (when (not (search-backward "<" nil t))
              (setq done t))
          (if (search-backward "<" nil t)
              (if (looking-at "</")
                  (incf depth)
                (if (= depth 0)
                    (setq done t)
                  (decf depth)))
            (setq done t))))
      (current-indentation))))

(defun urweb-calculate-indentation ()
  (save-excursion
    (beginning-of-line) (skip-chars-forward "\t ")
