From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: help with font locking Date: Thu, 12 Jan 2006 10:31:56 -0700 Message-ID: References: <2hhxf.91$Jd.25@newssvr25.news.prodigy.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1137097320 1675 80.91.229.2 (12 Jan 2006 20:22:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 12 Jan 2006 20:22:00 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 12 21:21:59 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Ex8xJ-0003ER-BS for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Jan 2006 21:21:58 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ex8zO-0002Il-Sj for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Jan 2006 15:24:06 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ex6SJ-0000H5-UK for help-gnu-emacs@gnu.org; Thu, 12 Jan 2006 12:41:48 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ex6SG-0000Fy-HK for help-gnu-emacs@gnu.org; Thu, 12 Jan 2006 12:41:46 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ex6Or-0007dE-FC for help-gnu-emacs@gnu.org; Thu, 12 Jan 2006 12:38:13 -0500 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1Ex6Rh-0004Pc-Bc for help-gnu-emacs@gnu.org; Thu, 12 Jan 2006 12:41:09 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Ex6KU-0008OZ-Th for help-gnu-emacs@gnu.org; Thu, 12 Jan 2006 18:33:44 +0100 Original-Received: from 207.167.42.60 ([207.167.42.60]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 12 Jan 2006 18:33:42 +0100 Original-Received: from ihs_4664 by 207.167.42.60 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 12 Jan 2006 18:33:42 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Lines: 39 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 207.167.42.60 User-Agent: Mozilla Thunderbird 0.9 (X11/20041105) X-Accept-Language: en-us, en In-Reply-To: <2hhxf.91$Jd.25@newssvr25.news.prodigy.net> 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:32604 Archived-At: Mark P wrote: > I'm trying to edit my .emacs file so that in c++-mode a frequently used > user-defined type "Coord" is highlighted like any built-in type (int, > bool, etc.) I searched around for a while but found only very limited > information. The best I could produce was the following: > > ;; customize font-locking > (font-lock-add-keywords > 'c++-mode > '(("\\<\\(Coord\\)" 1 font-lock-type-face) > ) ) > > This sort of works. In a statement like: > > Coord fcn (Coord x); > > "Coord" is highlighted twice, but neither "fcn" nor "x" is. In a normal > statement like: > > int fcn (int x) > > "int" is highlighted as are "fcn" and "x". > > Can anyone suggest a way to make the behavior for Coord match that for > int. Any links to detail documentation on how this works would also be > appreciated. (For example, why all the quotes and slashes in the .emacs > code?) Maybe http://simon.nitro.dk/dotfiles/emacs/ctypes.el is what you need: (autoload 'ctypes-define-type "ctypes" "Add a new TYPE to current major mode and inform font-lock." t) (add-hook 'c++-mode-hook (lambda () (ctypes-define-type "Coord"))) -- Kevin Rodgers