# HG changeset patch # User Mike Williams # Date 1017663053 0 # Node ID 52b704431b5d0fda0dff1fcdda5742b6cf514092 # Parent 2630d8a52e4a3bd57888bb10b793acb63d735253 Remove redundant name-end attribute. Simplify parsing by assuming we always start within text. Make use of sgml-unclosed-tag-p. diff -r 2630d8a52e4a -r 52b704431b5d lisp/textmodes/xml-lite.el --- a/lisp/textmodes/xml-lite.el Mon Apr 01 12:08:38 2002 +0000 +++ b/lisp/textmodes/xml-lite.el Mon Apr 01 12:10:53 2002 +0000 @@ -53,9 +53,11 @@ ;; Parsing + (defstruct (xml-lite-tag - (:constructor xml-lite-make-tag (type start end name name-end))) - type start end name name-end) + (:constructor xml-lite-make-tag (type start end name))) + type start end name) + (defsubst xml-lite-parse-tag-name () "Skip past a tag-name, and return the name." (buffer-substring-no-properties @@ -70,79 +72,44 @@ (equal s (buffer-substring-no-properties (point) limit)))) (defun xml-lite-parse-tag-backward () - "Get information about the parent tag." - (let ((limit (point)) - tag-type tag-start tag-end name name-end) - (with-syntax-table sgml-tag-syntax-table - (cond - - ((null (re-search-backward "[<>]" nil t))) - - ((= ?> (char-after)) ;--- found tag-end --- - (setq tag-end (1+ (point))) - (goto-char tag-end) - (cond - ((xml-lite-looking-back-at "--") ; comment - (setq tag-type 'comment - tag-start (search-backward "" nil t))) - ((xml-lite-looking-at "![CDATA[") ; cdata - (setq tag-type 'cdata - tag-end (search-forward "]]>" nil t))) - (t - (goto-char tag-start) - (setq tag-end (ignore-errors (forward-sexp) (point))))))) - - (cond - - ((or tag-type (null tag-start))) - - ((= ?! (char-after (1+ tag-start))) ; declaration - (setq tag-type 'decl)) - - ((= ?? (char-after (1+ tag-start))) ; processing-instruction - (setq tag-type 'pi)) - - ((= ?/ (char-after (1+ tag-start))) ; close-tag - (goto-char (+ 2 tag-start)) - (setq tag-type 'close - name (xml-lite-parse-tag-name) - name-end (point))) - - ((member ; JSP tags etc - (char-after (1+ tag-start)) - '(?% ?#)) - (setq tag-type 'unknown)) - - (t - (goto-char (1+ tag-start)) - (setq tag-type 'open - name (xml-lite-parse-tag-name) - name-end (point)) - ;; check whether it's an empty tag - (if (or (and tag-end (eq ?/ (char-before (- tag-end 1)))) - (and (not sgml-xml-mode) - (member-ignore-case name sgml-empty-tags))) - (setq tag-type 'empty)))) - - (cond - (tag-start - (goto-char tag-start) - (xml-lite-make-tag tag-type tag-start tag-end name name-end)))))) + "Parse an SGML tag backward, and return information about the tag. +Assume that parsing starts from within a textual context. +Leave point at the beginning of the tag." + (let (tag-type tag-start tag-end name) + (search-backward ">") + (setq tag-end (1+ (point))) + (cond + ((xml-lite-looking-back-at "--") ; comment + (setq tag-type 'comment + tag-start (search-backward "