I am improving the C++ highlighting in Emacs with the minor mode: modern-cpp-font-lock.
Consider this following C++14 code:
int main() { int i = 1'2'3l; }
From cppreference.com
Optional single quotes(') may be inserted between the digits as a separator. They are ignored by the compiler.
In modern-cpp-font-lock, I set 1'2'3
to font-lock-constant-face
and I set the integer suffix l
to font-lock-keyword-face
.
In fundamental-mode
and modern-c++-font-lock-mode
activated, I see the expected result. However, with c++-mode
and modern-c++-font-lock-mode
activated, '2'
is highlighted as a string (l
is correctly font locked).
I know the highlighting rely on the principle "first come first served" - meaning rules will not apply on words already highlighted.
Do you know if it is possible to override font-lock of a major mode? Or is it possible to change the order of rules to apply the font-lock (for example, longer rules first)?