help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding keywords to cc-mode


From: Alan Mackenzie
Subject: Re: Adding keywords to cc-mode
Date: Wed, 13 Jun 2007 21:06:38 +0100
User-agent: Mutt/1.5.9i

Hi, Stefan!

On Wed, Jun 13, 2007 at 06:02:33PM +0200, Stefan Arentz wrote:
> 
> (I'm on Emacs 22.1)
 
Good Man!
 
> Is it possible to add new keywords to cc-mode for highlighting? I'm working on
> some simple 'Core Foundation' code for OS X and this C/C++ code typically has
> types with names like CFSomethingRef or kCFFooConstant. Is there an easy way
> to add regular expressions to cc-mode to recognize these and highlight them in
> a specific color?

As long as "specific color" means "font-lock-type-face", then yes.  Set
one or both of the variables called c-font-lock-extra-types,
c++-font-lock-extra-types to a regexp to recognise the type.  Something
like this (untestested):

   (setq c-font-lock-extra-types
    (concat "\_<"
     (regexp-opt '("CFSomethingRef" "kCFFooConstant") t)
     "\_>"))

should do the trick.  It's documented on page "Font Locking
Preliminaries" of the (new) CC Mode manual.

>  S.

-- 
Alan Mackenzie (Ittersbach, Germany).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]