[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Emacs HTML modes



Manoj Srivastava <srivasta@debian.org> wrote:

> >>"Michael" == Michael P Soulier <msoulier@mcss.cas.mcmaster.ca> writes:
> 
>   Michael>     Normally the font-lock faces are set during
>  Michael> initialization of emacs, either from default values or from
>  Michael> the user's ~/.emacs file (like in my case).  However,
>  Michael> psgml-mode can't use font-lock because instead of knowing
>  Michael> the patterns to specify to font-lock when the mode
>  Michael> initializes, it must first parse the DTD for the language
>  Michael> being used, and pull out the keywords from it.
> 
> 	Right.
> 
>  Michael> Why is it that this newly-parsed information cannot be used
>  Michael> to make a new dynamic call to font-lock? I understood that
>  Michael> lisp was quite a dynamically-bound language and such tricks
>  Michael> as common in Perl and Python were done much earlier in
>  Michael> Lisp. Forgive my ignorance of the font-lock API. As I
>  Michael> understand it, you can call font-lock, passing it a list of
>  Michael> regexp patterns and corresponding faces for that pattern. I
>  Michael> don't follow why updating the patterns and re-fontifying
>  Michael> can't be done.
> 
> 	I guess one would have to ask the author. I suspect the
>  answers may have to do with the timeline of the feature appearing in
>  various flavours of emacsen and in psgml, whether it was easy to do a
>  consistent font-locking in all the supported emacsen flavours, or
>  whether he just preferred his  own implementation at that point.

It could be done.  One clean way to do it would be for
font-lock-defaults to define a function to call, instead of regexps, to
return patterns to fontify.  Another, perhaps simpler way, is for any
initialization code that brings in DTD definitions to also add
regexps to font-lock-defaults.

Two cents from someone who codes up font-lock for various modes.

Peter



Reply to: