[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Background colors in font-lock-keywords
From: |
Jesse Sheidlower |
Subject: |
Background colors in font-lock-keywords |
Date: |
27 May 2003 07:53:04 -0400 |
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.
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))
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)
, 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.
Second, is there a way to associate a background color with a particular
buffer only? For this same mode, I would like to get a lighly shaded
background with white as the main background color for actual sgml (i.e.
at the end of a line, text will appear light gray after the last closing
tag). I have accomplished this by, in my mode definition,
(set-background-color "gray90")
and then in my font-lock-keywords,
("^\\(<.*>\\)$" 1 my-background-face keep)
, with my-background-face defined as just having a white background,
and then (to solve the same problem as above) having other faces
inherit from this background. Is there a better way to do this? One
particular problem is that when I kill a buffer in this mode, I'm left
with a light-gray buffer wherever else I am, which is annoying, so
at the least I'd like a way to get the grayness to be associated only
with something in this mode.
Thanks.
Jesse Sheidlower
- Background colors in font-lock-keywords,
Jesse Sheidlower <=