From 80fc318ee869f92e811cd05b6cec2d6c3fd9359c Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Tue, 2 Apr 2002 12:07:27 +0000 Subject: [PATCH] (sgml-looking-back-at): Short-circuit at beg of buffer. (sgml-lexical-context,sgml-calculate-indent): Add support for CDATA sections. --- lisp/ChangeLog | 5 ++++- lisp/textmodes/sgml-mode.el | 27 +++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index df123ce238..b5cc06f5f6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,9 +1,12 @@ 2002-04-02 Mike Williams - * sgml-mode.el (sgml-close-tag): Rename from + * textmodes/sgml-mode.el (sgml-close-tag): Rename from sgml-insert-end-tag. Simplify by using sgml-lexical-context. (sgml-get-context): Remove use of sgml-inside-tag-p. (sgml-inside-tag-p): Remove. + (sgml-looking-back-at): Short-circuit at beg of buffer. + (sgml-lexical-context,sgml-calculate-indent): Add support for + CDATA sections. 2002-04-01 Stefan Monnier diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 4b01d4d291..74f3f50d32 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -872,26 +872,29 @@ If non-nil LIMIT is a nearby position before point outside of any tag." ;; 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 . - (setq state (parse-partial-sexp (point) pos 0))) + (setq cdata-start (if (looking-at "" 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 @@ With prefix argument, unquote the region." (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 @@ If FULL is non-nil, parse back to the beginning of the buffer." (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. -- 2.20.1