From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Oliver Scholz Newsgroups: gmane.emacs.help Subject: Re: Background colors in font-lock-keywords Date: Wed, 28 May 2003 00:23:57 +0200 Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1054074630 31087 80.91.224.249 (27 May 2003 22:30:30 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 27 May 2003 22:30:30 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Wed May 28 00:30:29 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19Kmwe-00081S-00 for ; Wed, 28 May 2003 00:29:24 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19Kmxp-0003Bo-II for gnu-help-gnu-emacs@m.gmane.org; Tue, 27 May 2003 18:30:37 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.gamma.ru!Gamma.RU!fu-berlin.de!uni-berlin.de!dialin-145-254-193-203.arcor-ip.NET!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 55 Original-NNTP-Posting-Host: dialin-145-254-193-203.arcor-ip.net (145.254.193.203) Original-X-Trace: fu-berlin.de 1054074319 4443111 145.254.193.203 (16 [87814]) X-Attribution: os X-Face: "HgH2sgK|bfH$; PiOJI6|qUCf.ve<51_Od(%ynHr?=>znn#~#oS>",F%B8&\vus),2AsPYb -n>PgddtGEn}s7kH?7kH{P_~vu?]OvVN^qD(L)>G^gDCl(U9n{:d>'DkilN!_K"eNzjrtI4Ya6;Td% IZGMbJ{lawG+'J>QXPZD&TwWU@^~A}f^zAb[Ru;CT(UA]c& User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.3.50 (windows-nt) Cancel-Lock: sha1:iRggMDCrVgAfe8MyzU568pwVql8= Original-Xref: shelby.stanford.edu gnu.emacs.help:113761 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:10256 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:10256 jester@panix.com (Jesse Sheidlower) writes: [...] > 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 > > ("\\(.*?\\)" 1 my-title-face t) > > , with my-title-face having a light-green background, then I > would like an entity reference used in a to be red but > also with a light-green background. Is there any way of > accomplishing this? I've been experimenting to no avail. Use the `prepend' or `append' keyword. For example: (defface example-l-word-face '((t (:background "Seagreen4"))) "Face used for words beginning with \"l\".") (defvar example-font-lock-keywords '(("\\<lirum\\>" . 'font-lock-warning-face) ("\\<larum\\>" . 'font-lock-keyword-face) ("\\<l\\w+" (0 'example-l-word-face append)))) (define-derived-mode example-mode text-mode "EXAMPLE" "Example mode for testing font lock keywords." (setq font-lock-defaults '(example-font-lock-keywords))) > Second, is there a way to associate a background color with a particular > buffer only? [...] Unfortunately there isn't a way to do this. The thing that comes closest to this is something like: (set (make-local-variable 'default-text-properties) '(face example-l-word-face)) The disadvantages are obvious. Oliver -- 9 Prairial an 211 de la Révolution Liberté, Egalité, Fraternité!