# HG changeset patch # User Stefan Monnier # Date 1178607458 0 # Node ID f46158b1c8bc69215cc842098d953aefd90afd35 # Parent 51b85ee9ab0f0414f956920b5aa365a0be3ead8f (sgml-lexical-context): Add handling of XML style Processing Instructions. (sgml-parse-tag-backward): Handle XML-style PIs. Also ensure progress. (sgml-calculate-indent): Handle `pi' context. diff -r 51b85ee9ab0f -r f46158b1c8bc lisp/ChangeLog --- a/lisp/ChangeLog Tue May 08 04:26:41 2007 +0000 +++ b/lisp/ChangeLog Tue May 08 06:57:38 2007 +0000 @@ -1,5 +1,10 @@ 2007-05-08 Stefan Monnier + * textmodes/sgml-mode.el (sgml-lexical-context): Add handling of + XML style Processing Instructions. + (sgml-parse-tag-backward): Handle XML-style PIs. Also ensure progress. + (sgml-calculate-indent): Handle `pi' context. + * vc.el: Ensure that update-changelog issues an error when used with a backend that does not implement it. (vc-update-changelog-rcs2log): Rename from vc-default-update-changelog. diff -r 51b85ee9ab0f -r f46158b1c8bc lisp/textmodes/sgml-mode.el --- a/lisp/textmodes/sgml-mode.el Tue May 08 04:26:41 2007 +0000 +++ b/lisp/textmodes/sgml-mode.el Tue May 08 06:57:38 2007 +0000 @@ -937,7 +937,7 @@ (defun sgml-lexical-context (&optional limit) "Return the lexical context at point as (TYPE . START). START is the location of the start of the lexical element. -TYPE is one of `string', `comment', `tag', `cdata', or `text'. +TYPE is one of `string', `comment', `tag', `cdata', `pi', or `text'. Optional argument LIMIT is the position to start parsing from. If nil, start from a preceding tag at indentation." @@ -964,12 +964,19 @@ (let ((cdata-start (point))) (unless (search-forward "]]>" pos 'move) (list 0 nil nil 'cdata nil nil nil nil cdata-start)))) + ((and sgml-xml-mode (looking-at "<\\?")) + ;; Processing Instructions. + ;; In SGML, it's basically a normal tag of the form + ;; but in XML, it takes the form . + (let ((pi-start (point))) + (unless (search-forward "?>" pos 'move) + (list 0 nil nil 'pi nil nil nil nil pi-start)))) (t ;; We've reached a tag. Parse it. ;; FIXME: Handle net-enabling start-tags (parse-partial-sexp (point) pos 0)))))) (cond - ((eq (nth 3 state) 'cdata) (cons 'cdata (nth 8 state))) + ((memq (nth 3 state) '(cdata pi)) (cons (nth 3 state) (nth 8 state))) ((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))) @@ -1093,9 +1100,15 @@ (when (eq (char-after) ?<) ;; Oops!! Looks like we were not in a textual context after all!. ;; Let's try to recover. + ;; Remember the tag-start so we don't need to look for it later. + ;; This is not just an optimization but also makes sure we don't get + ;; stuck in infloops in cases where "looking back for <" would not go + ;; back far enough. + (setq tag-start (point)) (with-syntax-table sgml-tag-syntax-table (let ((pos (point))) (condition-case nil + ;; FIXME: This does not correctly skip over PI an CDATA tags. (forward-sexp) (scan-error ;; This < seems to be just a spurious one, let's ignore it. @@ -1110,33 +1123,41 @@ (cond ((sgml-looking-back-at "--") ; comment (setq tag-type 'comment - tag-start (search-backward "