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

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

Re: help with font locking


From: Kevin Rodgers
Subject: Re: help with font locking
Date: Thu, 12 Jan 2006 10:31:56 -0700
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

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





reply via email to

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