Where I work we use a lot of our own custom data types. The c++ that emacs recognizes, notices many of the custom datatypes from the STL such as string, vector, etc. This means that in my editor if i declare a function like so:
string getString() const {
return str;
}
The return value will be highlighted green and due to this the function name will in blue. Now if I decide to use a custom string this messes everything up. So now my cpp files are mostly in white because we don't use the normal stl classes here. How can I program my emacs editor to recognize that when I mean 'String', color it the same way you would as 'string'?
You need font-lock-add-keywords. Here's an example:
(font-lock-add-keywords 'cc-mode
'(("String" . font-lock-type-face)
("str" . font-lock-type-face)))
It adds a list of regular expression/font lock pairs.
There's much more to be read on the topic of adding-keywords. In particular, ctypes.el might be of interest to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With