unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Glenn Morris <gmorris+news@ast.cam.ac.uk>
Subject: Re: Adding font-lock keywords
Date: Tue, 22 Apr 2003 11:05:32 +0100	[thread overview]
Message-ID: <ex65p6u9sj.fsf@xpc21.ast.cam.ac.uk> (raw)
In-Reply-To: 82f061b2.0304211305.334e187@posting.google.com

Brendan Van Horn wrote:

> (setq my-win32-constant-keywords
>       (regexp-opt
>        '("COINIT_MULTITHREADED" "ICC_COOL_CLASSES" "NULL" "SW_SHOWDEFAULT"
> 	 "VT_BSTR" "VT_I4")))
>
> (font-lock-add-keywords
>  'c++-mode
>  '((my-win32-constant-keywords . font-lock-constant-face)))

Use of a single-quote ' prevents symbols from being evaluated.

Compare:

my-win32-constant-keywords

with

'my-win32-constant-keywords

by putting the cursor at the end of the line and using C-x C-e. What
you are doing is adding the symbol my-win32-constant-keywords to the
keywords list, rather than its value.

You could use

(font-lock-add-keywords
 'c++-mode
 `((,my-win32-constant-keywords . font-lock-constant-face)))

because ` acts like ' except that anything preceded by a comma gets
evaluated. Or you could use:

(font-lock-add-keywords
 'c++-mode
 (list
  (cons my-win32-constant-keywords font-lock-constant-face)))

  reply	other threads:[~2003-04-22 10:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-21 21:05 Adding font-lock keywords Brendan Van Horn
2003-04-22 10:05 ` Glenn Morris [this message]
2003-04-22 17:10   ` Brendan Van Horn

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ex65p6u9sj.fsf@xpc21.ast.cam.ac.uk \
    --to=gmorris+news@ast.cam.ac.uk \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).