From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Arentz Newsgroups: gmane.emacs.help Subject: Re: Adding keywords to cc-mode Date: 13 Jun 2007 22:03:16 +0200 Message-ID: <87bqfj4o6z.fsf@kip.sateh.com> References: <87vedr4zc6.fsf@kip.sateh.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1181767260 11803 80.91.229.12 (13 Jun 2007 20:41:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 13 Jun 2007 20:41:00 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 13 22:40:59 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HyZeE-0007LD-Ra for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Jun 2007 22:40:59 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HyZeE-0007WM-Dp for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Jun 2007 16:40:58 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!feeder.news-service.com!feeder1.cambrium.nl!feed.tweaknews.nl!62.216.30.27.MISMATCH!newsgate.cistron.nl!xs4all!transit1.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 Original-Lines: 36 Original-NNTP-Posting-Host: 82.94.203.90 Original-X-Trace: 1181764996 news.xs4all.nl 337 [::ffff:82.94.203.90]:60098 Original-X-Complaints-To: abuse@xs4all.nl Original-Xref: shelby.stanford.edu gnu.emacs.help:149435 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:45024 Archived-At: Alan Mackenzie 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.