On 06 Sep 2002, ville.skytta(a)xemacs.org wrote:
Adrian, could you elaborate a bit on why it is necessary to put
html-font-lock-keywords into effect when one is editing an XML file [1]?
There were several complaints on the mailing lists about xml mode not
fontifying.
(put 'xml-mode 'font-lock-defaults '(html-font-lock-keywords nil t))
The problem is that without the above html-font-lock hack, xml-mode
does not do font locking. xml-mode does some sort of font locking if
you have set various configuration variables sgml-auto-activate-dtd
and sgml-set-face. If these variables are set, then xml code will be
fontified according to sgml-markup-faces.
For example, here was my effort at getting something without the
html-font-lock-keywords hack.
(setq-default sgml-auto-activate-dtd t)
(setq-default sgml-set-face t)
(setq-default sgml-markup-faces
'((start-tag . font-lock-keyword-face)
(end-tag . font-lock-keyword-face)
(ignored . font-lock-string-face)
(ms-start . font-lock-other-type-face)
(ms-end . font-lock-other-type-face)
(shortref . font-lock-reference-face)
(entity . font-lock-reference-face)
(comment . font-lock-comment-face)
(pi . custom-changed-face)
(sgml . font-lock-function-name-face)
(doctype . font-lock-emphasized-face)))
sgml-auto-activate-dtd causes other things to happen. Anyway,
Eventually, you get some sort of font locking. I gave up the
markup-faces and went back to using the html font lock keywords.
Those keywords contain stuff that is plain wrong in XML, such as
fontifying stuff inside the <strong> tag in bold.
Maybe. If you have xhtml stuff mixed in it would be correct?
Fontification in psgml is certainly a Very Good Thing, but I think
the
current approach is not correct. Additionally, psgml-parse.el already
has some fontification stuff (not font-lock), and mixing font-lock with
it might produce weird side effects. At least my XEmacs behaves pretty
unexpectedly when editing HTML files nowadays, try it out like this:
1) Start XEmacs, C-x C-f doesnt_exist.html RET
2) Fill in the document title
3) Note the colours
4) Go down below the <h1> tag, hit TAB
5) Watch the colours change
I think this is because psgml's own fontification kicks in when one hits
the TAB in the above. Doing M-x font-lock-fontify-buffer RET brings
back a consistent state (ie. the one that psgml-html and its font-lock
does), but editing the buffer after that again changes the colours.
I've noticed that as well. This xml-mode font-lock hack wouldn't
explain this particular problem though? html-mode doesn't call
xml-mode? Right?
As you already note in [1], this is the first cut and most likely
work
in progress, but could you give any estimates how/when/if you're
planning to continue the work? I'm afraid that we'll start receiving
bug reports about this soon...
[1]
<
http://list-archive.xemacs.org/xemacs-patches/200112/msg00169.html >
-jeff