aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Williams2002-04-03 21:17:38 +0000
committerMike Williams2002-04-03 21:17:38 +0000
commit14614b6d3a860788bb413be595ca297b7e178145 (patch)
tree66e33cdf2d633a1ce3736900964224227f91636e
parentad77ae0bcf4e4f97d4cf383749f9a5b064239a75 (diff)
downloademacs-14614b6d3a860788bb413be595ca297b7e178145.tar.gz
emacs-14614b6d3a860788bb413be595ca297b7e178145.zip
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
-rw-r--r--lisp/textmodes/sgml-mode.el35
1 files changed, 21 insertions, 14 deletions
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 49201f5a893..b308915c948 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -872,29 +872,36 @@ If non-nil LIMIT is a nearby position before point outside of any tag."
872 ;; any string or tag or comment or ... 872 ;; any string or tag or comment or ...
873 (save-excursion 873 (save-excursion
874 (let ((pos (point)) 874 (let ((pos (point))
875 text-start cdata-start state) 875 text-start state)
876 (if limit (goto-char limit) 876 (if limit (goto-char limit)
877 ;; Hopefully this regexp will match something that's not inside 877 ;; Hopefully this regexp will match something that's not inside
878 ;; a tag and also hopefully the match is nearby. 878 ;; a tag and also hopefully the match is nearby.
879 (re-search-backward "^[ \t]*<[_:[:alpha:]/%!?#]" nil 'move)) 879 (re-search-backward "^[ \t]*<[_:[:alpha:]/%!?#]" nil 'move))
880 ;; (setq text-start (point))
881 (with-syntax-table sgml-tag-syntax-table 880 (with-syntax-table sgml-tag-syntax-table
882 (while (< (point) pos) 881 (while (< (point) pos)
883 ;; When entering this loop we're inside text. 882 ;; When entering this loop we're inside text.
884 (setq text-start (point)) 883 (setq text-start (point))
885 (skip-chars-forward "^<" pos) 884 (skip-chars-forward "^<" pos)
886 (setq cdata-start (if (looking-at "<!\\[[A-Z]+\\[") (point))) 885 (setq state
887 ;; We skipped text and reached a tag. Parse it. 886 (cond
888 ;; FIXME: Handle net-enabling start-tags 887 ((= (point) pos)
889 (if cdata-start 888 ;; We got to the end without seeing a tag.
890 (search-forward "]]>" pos 'move) 889 nil)
891 (setq state (parse-partial-sexp (point) pos 0)))) 890 ((looking-at "<!\\[[A-Z]+\\[")
892 (cond 891 ;; We've found a CDATA section or similar.
893 (cdata-start (cons 'cdata cdata-start)) 892 (let ((cdata-start (point)))
894 ((nth 3 state) (cons 'string (nth 8 state))) 893 (unless (search-forward "]]>" pos 'move)
895 ((nth 4 state) (cons 'comment (nth 8 state))) 894 (list 0 nil nil 'cdata nil nil nil nil cdata-start))))
896 ((and state (> (nth 0 state) 0)) (cons 'tag (nth 1 state))) 895 (t
897 (t (cons 'text text-start))))))) 896 ;; We've reached a tag. Parse it.
897 ;; FIXME: Handle net-enabling start-tags
898 (parse-partial-sexp (point) pos 0))))))
899 (cond
900 ((eq (nth 3 state) 'cdata) (cons 'cdata (nth 8 state)))
901 ((nth 3 state) (cons 'string (nth 8 state)))
902 ((nth 4 state) (cons 'comment (nth 8 state)))
903 ((and state (> (nth 0 state) 0)) (cons 'tag (nth 1 state)))
904 (t (cons 'text text-start))))))
898 905
899(defun sgml-beginning-of-tag (&optional top-level) 906(defun sgml-beginning-of-tag (&optional top-level)
900 "Skip to beginning of tag and return its name. 907 "Skip to beginning of tag and return its name.