- (skip-chars-forward "^ \t\n") ;Skip tag name.
- (skip-chars-forward " \t")
- (if (not (eolp))
- (current-column)
- ;; This is the first attribute: indent.
- (goto-char (1+ (cdr lcon)))
- (+ (current-column) sgml-basic-offset)))
-
- (text
- (while (looking-at "</")
- (forward-sexp 1)
- (skip-chars-forward " \t"))
- (let* ((here (point))
- (unclosed (and ;; (not sgml-xml-mode)
- (looking-at sgml-tag-name-re)
- (member-ignore-case (match-string 1)
- sgml-unclosed-tags)
- (match-string 1)))
- (context
- ;; If possible, align on the previous non-empty text line.
- ;; Otherwise, do a more serious parsing to find the
- ;; tag(s) relative to which we should be indenting.
- (if (and (not unclosed) (skip-chars-backward " \t")
- (< (skip-chars-backward " \t\n") 0)
- (back-to-indentation)
- (> (point) (cdr lcon)))
- nil
- (goto-char here)
- (nreverse (sgml-get-context (if unclosed nil 'empty)))))
- (there (point)))
- ;; Ignore previous unclosed start-tag in context.
- (while (and context unclosed
- (eq t (compare-strings
- (sgml-tag-name (car context)) nil nil
- unclosed nil nil t)))
- (setq context (cdr context)))
- ;; Indent to reflect nesting.
- (if (and context
- (goto-char (sgml-tag-end (car context)))
- (skip-chars-forward " \t\n")
- (< (point) here) (sgml-at-indentation-p))
- (current-column)
- (goto-char there)
- (+ (current-column)
- (* sgml-basic-offset (length context))))))
-
- (otherwise
- (error "Unrecognised context %s" (car lcon)))
-
- )))
+ (+ (current-column) sgml-basic-offset)))
+
+ (text
+ (while (looking-at "</")
+ (forward-sexp 1)
+ (skip-chars-forward " \t"))
+ (let* ((here (point))
+ (unclosed (and ;; (not sgml-xml-mode)
+ (looking-at sgml-tag-name-re)
+ (member-ignore-case (match-string 1)
+ sgml-unclosed-tags)
+ (match-string 1)))
+ (context
+ ;; If possible, align on the previous non-empty text line.
+ ;; Otherwise, do a more serious parsing to find the
+ ;; tag(s) relative to which we should be indenting.
+ (if (and (not unclosed) (skip-chars-backward " \t")
+ (< (skip-chars-backward " \t\n") 0)
+ (back-to-indentation)
+ (> (point) (cdr lcon)))
+ nil
+ (goto-char here)
+ (nreverse (sgml-get-context (if unclosed nil 'empty)))))
+ (there (point)))
+ ;; Ignore previous unclosed start-tag in context.
+ (while (and context unclosed
+ (eq t (compare-strings
+ (sgml-tag-name (car context)) nil nil
+ unclosed nil nil t)))
+ (setq context (cdr context)))
+ ;; Indent to reflect nesting.
+ (cond
+ ;; If we were not in a text context after all, let's try again.
+ ((and context (> (sgml-tag-end (car context)) here))
+ (goto-char here)
+ (sgml-calculate-indent
+ (cons (if (memq (sgml-tag-type (car context)) '(comment cdata))
+ (sgml-tag-type (car context)) 'tag)
+ (sgml-tag-start (car context)))))
+ ;; Align on the first element after the nearest open-tag, if any.
+ ((and context
+ (goto-char (sgml-tag-end (car context)))
+ (skip-chars-forward " \t\n")
+ (< (point) here) (sgml-at-indentation-p))
+ (current-column))
+ (t
+ (goto-char there)
+ (+ (current-column)
+ (* sgml-basic-offset (length context)))))))
+
+ (otherwise
+ (error "Unrecognised context %s" (car lcon)))
+
+ ))