>>>>> "PF" == Peter Flynn <peter@...> writes:
PF> D. D. Brierton wrote:
>> On Tue, 2002-11-26 at 19:04, Artiom Neganov wrote:
AN> In short, when colorizing will work in Emacs? :)
DDB> I can't help agreeing that syntax highlighting could be much
DDB> improved in PSGML. It is also a regularly requested
DDB> feature. Is it hard to do?
PF> I don't understand the problem. Syntactic fontification
PF> (colorizing) I thought is ALREADY IN the major modes (psgml,
PF> xxml, xslide, etc).
PF> Maybe the OP's question was really "how do I turn it on", not
PF> "has anyone ever implemented it". In fact, looking at the
PF> wording "when colorizing will work" (aside from the inversion)
PF> I think the answer is actually:
PF> Add the following to your .emacs file:
PF> (require 'font-lock) (global-font-lock-mode t)
PF> (setq font-lock-maximum-decoration t) (turn-on-font-lock)
You should be able to set something like that via the Options menu,
PF> I can't guarantee it will work because I don't understand
PF> Elisp, but that's what's in my .emacs, and I get color.
If you want to go deeper, I recommend Markus Hoenicka's 'SGML Tools
under Windows NT' page (which is a slight misnomer, as it starts out
by installing CygWin ;-). The section on psgml explains how to set up
and customize font-locking:
(take the 'cygx646.html' part with a grain of salt; Markus seems to
have worked on this since I last visited the site.)
This, however, does not highlight attributes. For this, I have added
the following (simplistic) bits:
'(" \\([^> ]+\\) *=" 1 font-lock-variable-name-face t)
'("=[ \t\n]*\\(\"[^\"]+\"\\)" 1 font-lock-string-face t)
"Additional expressions to highlight in XML mode.
Remotely based on the one for psgml-html, basically an extended
version of attribute definitions. The remainder is fontified by psgml
itself. See `sgml-markup-faces' and `sgml-set-face'.")
(defun sgml-activate-syntax-highlighting ()
"Activate syntax highlighting based on psgml parsing.
This is a general configuration function intended to abstract from all
that setup business. It is not intended to be called from mode hooks.
This is based on
Step 6, \"Enable syntax coloring\", which is based on code by David
Megginson. Edited to be more minimal and integrated into the general
;; In sgml documents, parse dtd immediately to allow immediate
;; syntax coloring. Off by default.
(setq sgml-auto-activate-dtd t)
;; Actually have syntax coloring applied by psgml.
(setq-default sgml-set-face t)
(put 'xml-mode 'font-lock-defaults '(i3-xml-font-lock-keywords nil t))
;; So it's not really SGML font-locking --- watch me care.
(put 'sgml-mode 'font-lock-defaults '(i3-xml-font-lock-keywords nil t))
(I recommend you play around a little with
sgml-activate-syntax-highlighting, commenting out s-expressions one by
one to see wether it does anything useful for you.)
You'll notice soon that this simplistic font-locking is very
nonperfect. Things like
<!-- ======================= -->
while not really uncommon, look a bit funny. But I'm reluctant to
play around with the font-locking regexps, as they do tend to eat up
enough startup time already.
Felix H. Gatzemeier fxg@...
Office Phone: (0(049)241)80-21313
Disclaimer: I do not speak for anyone but myself.
Please do not send me mails containing documents in proprietary
formats (such as Microsoft Word) unless you really need to.