changeset 44335:1a7be1d554f5

(sgml-looking-back-at): Short-circuit at beg of buffer. (sgml-lexical-context,sgml-calculate-indent): Add support for CDATA sections.
author Mike Williams <mdub@bigfoot.com>
date Tue, 02 Apr 2002 12:06:26 +0000
parents 3aa56f622b1b
children 606cd09a7ed4
files lisp/textmodes/sgml-mode.el
diffstat 1 files changed, 17 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/sgml-mode.el	Tue Apr 02 11:31:33 2002 +0000
+++ b/lisp/textmodes/sgml-mode.el	Tue Apr 02 12:06:26 2002 +0000
@@ -872,26 +872,29 @@
   ;; any string or tag or comment or ...
   (save-excursion
     (let ((pos (point))
-	  (state nil)
-	  textstart)
+	  text-start cdata-start state)
       (if limit (goto-char limit)
 	;; Hopefully this regexp will match something that's not inside
 	;; a tag and also hopefully the match is nearby.
 	(re-search-backward "^[ \t]*<[_:[:alpha:]/%!?#]" nil 'move))
-      (setq textstart (point))
+      ;; (setq text-start (point))
       (with-syntax-table sgml-tag-syntax-table
 	(while (< (point) pos)
 	  ;; When entering this loop we're inside text.
-	  (setq textstart (point))
+	  (setq text-start (point))
 	  (skip-chars-forward "^<" pos)
-	  ;; We skipped text and reached a tag.  Parse it.
-	  ;; FIXME: Handle net-enabling start-tags and <![CDATA[ ...]]>.
-	  (setq state (parse-partial-sexp (point) pos 0)))
+          (setq cdata-start (if (looking-at "<!\\[CDATA\\[") (point)))
+          ;; We skipped text and reached a tag.  Parse it.
+          ;; FIXME: Handle net-enabling start-tags
+          (if cdata-start
+              (search-forward "]]>" pos 'limit)
+            (setq state (parse-partial-sexp (point) pos 0))))
 	(cond
+         (cdata-start  (cons 'cdata cdata-start))
 	 ((nth 3 state) (cons 'string (nth 8 state)))
 	 ((nth 4 state) (cons 'comment (nth 8 state)))
 	 ((and state (> (nth 0 state) 0)) (cons 'tag (nth 1 state)))
-	 (t (cons 'text textstart)))))))
+	 (t (cons 'text text-start)))))))
 
 (defun sgml-beginning-of-tag (&optional top-level)
   "Skip to beginning of tag and return its name.
@@ -961,8 +964,9 @@
    (point) (progn (skip-syntax-forward "w_") (point))))
 
 (defsubst sgml-looking-back-at (s)
-  (let ((limit (max (- (point) (length s)) (point-min))))
-    (equal s (buffer-substring-no-properties limit (point)))))
+  (let ((start (- (point) (length s))))
+    (and (>= start (point-min))
+         (equal s (buffer-substring-no-properties start (point))))))
 
 (defun sgml-parse-tag-backward ()
   "Parse an SGML tag backward, and return information about the tag.
@@ -1151,6 +1155,9 @@
 	   (forward-char 2) (skip-chars-forward " \t"))
 	 (current-column)))
 
+      (cdata
+       (current-column))
+
       (tag
        (goto-char (1+ (cdr lcon)))
        (skip-chars-forward "^ \t\n")	;Skip tag name.