diff options
| author | Mike Williams | 2002-04-02 12:07:27 +0000 |
|---|---|---|
| committer | Mike Williams | 2002-04-02 12:07:27 +0000 |
| commit | 80fc318ee869f92e811cd05b6cec2d6c3fd9359c (patch) | |
| tree | d07db7a18635578708678619bb584760bf398596 | |
| parent | 34e839fde4312a875e62f5c96b864c09f1490f86 (diff) | |
| download | emacs-80fc318ee869f92e811cd05b6cec2d6c3fd9359c.tar.gz emacs-80fc318ee869f92e811cd05b6cec2d6c3fd9359c.zip | |
(sgml-looking-back-at): Short-circuit at beg of buffer.
(sgml-lexical-context,sgml-calculate-indent): Add support for
CDATA sections.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/textmodes/sgml-mode.el | 27 |
2 files changed, 21 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index df123ce2380..b5cc06f5f66 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,9 +1,12 @@ | |||
| 1 | 2002-04-02 Mike Williams <mdub@bigfoot.com> | 1 | 2002-04-02 Mike Williams <mdub@bigfoot.com> |
| 2 | 2 | ||
| 3 | * sgml-mode.el (sgml-close-tag): Rename from | 3 | * textmodes/sgml-mode.el (sgml-close-tag): Rename from |
| 4 | sgml-insert-end-tag. Simplify by using sgml-lexical-context. | 4 | sgml-insert-end-tag. Simplify by using sgml-lexical-context. |
| 5 | (sgml-get-context): Remove use of sgml-inside-tag-p. | 5 | (sgml-get-context): Remove use of sgml-inside-tag-p. |
| 6 | (sgml-inside-tag-p): Remove. | 6 | (sgml-inside-tag-p): Remove. |
| 7 | (sgml-looking-back-at): Short-circuit at beg of buffer. | ||
| 8 | (sgml-lexical-context,sgml-calculate-indent): Add support for | ||
| 9 | CDATA sections. | ||
| 7 | 10 | ||
| 8 | 2002-04-01 Stefan Monnier <monnier@cs.yale.edu> | 11 | 2002-04-01 Stefan Monnier <monnier@cs.yale.edu> |
| 9 | 12 | ||
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 4b01d4d2917..74f3f50d328 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." | |||
| 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 | (state nil) | 875 | text-start cdata-start state) |
| 876 | textstart) | ||
| 877 | (if limit (goto-char limit) | 876 | (if limit (goto-char limit) |
| 878 | ;; Hopefully this regexp will match something that's not inside | 877 | ;; Hopefully this regexp will match something that's not inside |
| 879 | ;; a tag and also hopefully the match is nearby. | 878 | ;; a tag and also hopefully the match is nearby. |
| 880 | (re-search-backward "^[ \t]*<[_:[:alpha:]/%!?#]" nil 'move)) | 879 | (re-search-backward "^[ \t]*<[_:[:alpha:]/%!?#]" nil 'move)) |
| 881 | (setq textstart (point)) | 880 | ;; (setq text-start (point)) |
| 882 | (with-syntax-table sgml-tag-syntax-table | 881 | (with-syntax-table sgml-tag-syntax-table |
| 883 | (while (< (point) pos) | 882 | (while (< (point) pos) |
| 884 | ;; When entering this loop we're inside text. | 883 | ;; When entering this loop we're inside text. |
| 885 | (setq textstart (point)) | 884 | (setq text-start (point)) |
| 886 | (skip-chars-forward "^<" pos) | 885 | (skip-chars-forward "^<" pos) |
| 887 | ;; We skipped text and reached a tag. Parse it. | 886 | (setq cdata-start (if (looking-at "<!\\[CDATA\\[") (point))) |
| 888 | ;; FIXME: Handle net-enabling start-tags and <![CDATA[ ...]]>. | 887 | ;; We skipped text and reached a tag. Parse it. |
| 889 | (setq state (parse-partial-sexp (point) pos 0))) | 888 | ;; FIXME: Handle net-enabling start-tags |
| 889 | (if cdata-start | ||
| 890 | (search-forward "]]>" pos 'limit) | ||
| 891 | (setq state (parse-partial-sexp (point) pos 0)))) | ||
| 890 | (cond | 892 | (cond |
| 893 | (cdata-start (cons 'cdata cdata-start)) | ||
| 891 | ((nth 3 state) (cons 'string (nth 8 state))) | 894 | ((nth 3 state) (cons 'string (nth 8 state))) |
| 892 | ((nth 4 state) (cons 'comment (nth 8 state))) | 895 | ((nth 4 state) (cons 'comment (nth 8 state))) |
| 893 | ((and state (> (nth 0 state) 0)) (cons 'tag (nth 1 state))) | 896 | ((and state (> (nth 0 state) 0)) (cons 'tag (nth 1 state))) |
| 894 | (t (cons 'text textstart))))))) | 897 | (t (cons 'text text-start))))))) |
| 895 | 898 | ||
| 896 | (defun sgml-beginning-of-tag (&optional top-level) | 899 | (defun sgml-beginning-of-tag (&optional top-level) |
| 897 | "Skip to beginning of tag and return its name. | 900 | "Skip to beginning of tag and return its name. |
| @@ -961,8 +964,9 @@ With prefix argument, unquote the region." | |||
| 961 | (point) (progn (skip-syntax-forward "w_") (point)))) | 964 | (point) (progn (skip-syntax-forward "w_") (point)))) |
| 962 | 965 | ||
| 963 | (defsubst sgml-looking-back-at (s) | 966 | (defsubst sgml-looking-back-at (s) |
| 964 | (let ((limit (max (- (point) (length s)) (point-min)))) | 967 | (let ((start (- (point) (length s)))) |
| 965 | (equal s (buffer-substring-no-properties limit (point))))) | 968 | (and (>= start (point-min)) |
| 969 | (equal s (buffer-substring-no-properties start (point)))))) | ||
| 966 | 970 | ||
| 967 | (defun sgml-parse-tag-backward () | 971 | (defun sgml-parse-tag-backward () |
| 968 | "Parse an SGML tag backward, and return information about the tag. | 972 | "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." | |||
| 1151 | (forward-char 2) (skip-chars-forward " \t")) | 1155 | (forward-char 2) (skip-chars-forward " \t")) |
| 1152 | (current-column))) | 1156 | (current-column))) |
| 1153 | 1157 | ||
| 1158 | (cdata | ||
| 1159 | (current-column)) | ||
| 1160 | |||
| 1154 | (tag | 1161 | (tag |
| 1155 | (goto-char (1+ (cdr lcon))) | 1162 | (goto-char (1+ (cdr lcon))) |
| 1156 | (skip-chars-forward "^ \t\n") ;Skip tag name. | 1163 | (skip-chars-forward "^ \t\n") ;Skip tag name. |