2001-10-15 09:52:39 PDT
I found the following slightly different solution was necessary: (I forget why I was unhappy with calling sgml-insert-end-tag directly, maybe something to do with how it behaves inside comments and PIs?)
(defun sgml-slash-check ()
"For psgml-mode, if you type `/' after `<', insert the appropriate
end tag, if there is an open element."
(interactive)
(if (= (char-before) 60)
;; Slash after <, let's end the current open element if we can
(progn
(sgml-parse-to-here)
(cond
((eq sgml-current-tree sgml-top-tree)
(insert "/"))
((not (sgml-final-p sgml-current-state))
(insert "/"))
(t (progn
(delete-backward-char 1)
(insert (sgml-end-tag-of sgml-current-tree))))))
(insert "/")))
I also found that the following (perhaps crude) patch to psgml-parse.el was necessary to make the XML predefined entities acceptable to the PSGML parser:
1688c1688,1703
< (cond ((and (null entity)
---
> (cond ((and sgml-xml-p (string= name "amp"))
> (sgml-push-to-entity (sgml-make-entity name "text" "&")
> sgml-markup-start))
> ((and sgml-xml-p (string= name "lt"))
> (sgml-push-to-entity (sgml-make-entity name "text" "<")
> sgml-markup-start))
> ((and sgml-xml-p (string= name "gt"))
> (sgml-push-to-entity (sgml-make-entity name "text" ">")
> sgml-markup-start))
> ((and sgml-xml-p (string= name "apos"))
> (sgml-push-to-entity (sgml-make-entity name "text" "'")
> sgml-markup-start))
> ((and sgml-xml-p (string= name "quot"))
> (sgml-push-to-entity (sgml-make-entity name "text" """)
> sgml-markup-start))
> ((and (null entity)