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: Jesse Sheidlower
Subject: Re: Background colors in font-lock-keywords
Date: 27 May 2003 13:12:05 -0400

In article <address@hidden>,
Kevin Rodgers  <address@hidden> wrote:
>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.

At least for now, I'm doing this in the most basic, kludgy way possible,
as I'm new to programming in Emacs Lisp. I'd be interested to see your
hacks as well!

>> 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

Yes, but this project is designed for a particular application and I
know the content of all of my entities.

In fact, I'm using a flavor of SGML where the period, rather than the
semicolon, signals the end of an entity reference, but I silently
changed it above to avoid having to explain it! That didn't work.

>> 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?

Again, for this application, the <title> tags only appear on a single
line; if it runs longer than 80 (or whatever) characters you just
keep going, without any newlines or returns.

Handling nested elements is what my question was about ;-). For
current purposes, the entity references are the only hard thing,
as the other elements I'm choosing to highlight aren't nested.
I was hoping that an answer to my original question would help
me solve the for-now-theoretical case of <title>This is a title
with <foo>something else</foo> inside</title>.

Best,

Jesse Sheidlower


reply via email to

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