From: Oliver Scholz <alkibiades@gmx.de>
Subject: Re: Background colors in font-lock-keywords
Date: Wed, 28 May 2003 00:23:57 +0200 [thread overview]
Message-ID: <uel2kc9ky.fsf@ID-87814.user.dfncis.de> (raw)
In-Reply-To: bavjj0$ot1$1@panix2.panix.com
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
>
> ("<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.
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é!
next prev parent reply other threads:[~2003-05-27 22:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-27 11:53 Background colors in font-lock-keywords Jesse Sheidlower
2003-05-27 14:35 ` Stefan Monnier
2003-05-28 16:09 ` Jesse Sheidlower
2003-05-27 16:30 ` Kevin Rodgers
2003-05-27 17:12 ` Jesse Sheidlower
2003-05-27 22:23 ` Oliver Scholz [this message]
2003-05-27 22:43 ` Oliver Scholz
2003-05-28 0:13 ` lawrence mitchell
2003-05-28 7:32 ` Oliver Scholz
2003-05-28 13:15 ` lawrence mitchell
2003-05-28 16:13 ` Oliver Scholz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=uel2kc9ky.fsf@ID-87814.user.dfncis.de \
--to=alkibiades@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.