[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding font-lock keywords
From: |
Glenn Morris |
Subject: |
Re: Adding font-lock keywords |
Date: |
Tue, 22 Apr 2003 11:05:32 +0100 |
User-agent: |
Gnus (www.gnus.org), GNU Emacs (www.gnu.org/directory/emacs.html) |
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)))