863 |
START is the location of the start of the lexical element. |
START is the location of the start of the lexical element. |
864 |
TYPE is one of `string', `comment', `tag', `cdata', or `text'. |
TYPE is one of `string', `comment', `tag', `cdata', or `text'. |
865 |
|
|
866 |
If non-nil LIMIT is a nearby position before point outside of any tag." |
Optional argument LIMIT is the position to start parsing from. |
867 |
;; As usual, it's difficult to get a reliable answer without parsing the |
If nil, start from a preceding tag at indentation." |
|
;; whole buffer. We'll assume that a tag at indentation is outside of |
|
|
;; any string or tag or comment or ... |
|
868 |
(save-excursion |
(save-excursion |
869 |
(let ((pos (point)) |
(let ((pos (point)) |
870 |
text-start state) |
text-start state) |
871 |
(if limit (goto-char limit) |
(if limit |
872 |
;; Hopefully this regexp will match something that's not inside |
(goto-char limit) |
873 |
;; a tag and also hopefully the match is nearby. |
;; Skip tags backwards until we find one at indentation |
874 |
(re-search-backward "^[ \t]*<[_:[:alpha:]/%!?#]" nil 'move)) |
(while (and (ignore-errors (sgml-parse-tag-backward)) |
875 |
|
(not (sgml-at-indentation-p))))) |
876 |
(with-syntax-table sgml-tag-syntax-table |
(with-syntax-table sgml-tag-syntax-table |
877 |
(while (< (point) pos) |
(while (< (point) pos) |
878 |
;; When entering this loop we're inside text. |
;; When entering this loop we're inside text. |
965 |
(buffer-substring-no-properties |
(buffer-substring-no-properties |
966 |
(point) (progn (skip-syntax-forward "w_") (point)))) |
(point) (progn (skip-syntax-forward "w_") (point)))) |
967 |
|
|
968 |
(defsubst sgml-looking-back-at (s) |
(defsubst sgml-looking-back-at (str) |
969 |
(let ((start (- (point) (length s)))) |
"Return t if the test before point matches STR." |
970 |
|
(let ((start (- (point) (length str)))) |
971 |
(and (>= start (point-min)) |
(and (>= start (point-min)) |
972 |
(equal s (buffer-substring-no-properties start (point)))))) |
(equal str (buffer-substring-no-properties start (point)))))) |
973 |
|
|
974 |
(defun sgml-parse-tag-backward () |
(defun sgml-parse-tag-backward () |
975 |
"Parse an SGML tag backward, and return information about the tag. |
"Parse an SGML tag backward, and return information about the tag. |