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: Stefan Arentz
Subject: Re: Adding keywords to cc-mode
Date: 13 Jun 2007 22:03:16 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

Alan Mackenzie <address@hidden> writes:

> 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.

Got it. That regexp-opt trick is nice. How predictable is that? If I
give it CFFooRef and CFBarRef is it then smart enough to make CF*Ref
match or wil it just match what you give it as an example?

There is no way to have a difference face for these extra types?

 S.


reply via email to

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