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")))