help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Background colors in font-lock-keywords


From: Kevin Rodgers
Subject: Re: Background colors in font-lock-keywords
Date: Tue, 27 May 2003 10:30:39 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Jesse Sheidlower wrote:

I'm developing a derived mode of psgml in order to set up my own
highlighting of particular tags and tag groups using font-lock,
and I'm having trouble with two things relating to the background
of faces I'm using.


I'd like to hear how your project turns out.  Several years ago I implemented
something similar, but instead of using font-lock (which wasn't mature at the
time) I hacked my own (ELEMENT . OVERLAY-PROPERTY-LIST) association list.  It
had some nice features, like using overlay priorities to handled element nesting
and a special function property so you could compute overlay properties
dynamically, but I didn't maintain it to keep up with Emacs and PSGML.  Now I
think the right approach would be to implement XSL support in Emacs.


First, I'd like certain faces to use as a background any other
element they happen to be on. For example, in my font-lock-keywords
section I define entity references for this application as:

  ("&[a-zA-z]+;" . (0 my-entity-face t))


Sorry I can't help you with your face questions.  But note that SGML's reference
concrete syntax (the default, used by PSGML) also allows digits, hyphen, and
period in entity names (just not as the first character); and XML additionally
allows underscore and colon (even as the first character) in entity names.  XML
also allows non-ASCII letters and other Unicode characters.  See

http://xml.coverpages.org/sgmlsyn/sgmlsyn.htm#P55
http://www.w3.org/TR/REC-xml#NT-Name


I've defined my-entity-face with a red foreground color and a
weight of bold. What I would like is for the background to
match whatever it's on, so that if there's an entity reference
in text that happens to be white, it will be red with a white
background, but if, in another font-lock-keywords expression,
I have defined

  ("<title>\\(.*?\\)</title>" 1 my-title-face t)


How do you handle elements that span more than 1 line?  Does font-lock handle
nested elements correctly for you?


, with my-title-face having a light-green background, then I
would like an entity reference used in a <title> to be red but
also with a light-green background. Is there any way of
accomplishing this? I've been experimenting to no avail.

...

--
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;";>Kevin Rodgers</a>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]