emacs-devel
[Top][All Lists]
Advanced

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

RE: FW: Font-lock misfontifies foo::bar in C++


From: Marshall, Simon
Subject: RE: FW: Font-lock misfontifies foo::bar in C++
Date: Tue, 25 Jul 2006 09:48:45 +0100

> > src/emacs -Q foo.cpp
>  
> > In the foo.cpp buffer, insert the text:
>  
> > void foo::bar()      // wrong - foo in font-lock-constant-face
(otherwise ok)
> 
> The face for "foo" is deliberately set to 
> c-reference-face-name (At cc-fonts.el L667 (in 
> (c-lang-defconst c-basic-matchers-before ....)).
> c-reference-face-name is defined (earlier on in the file) as 
> c-label-face-name, which (in its turn) becomes 
> font-lock-constant-face.
> 
> So this is quite deliberate.  I don't assert it's "right", 
> for whatever value of "right".  Maybe this could be described 
> more clearly in the CC Mode manual (on page "Faces").

Hi Alan, why is c-reference-face-name used for foo in this context?  It
cannot be a reference, it is a type name.

> > {
> >   foo                       ;// ok - no fontification
> 
> What is this, syntactically?  Is it valid C++?

The ; was just to ensure emacs indented following lines.

> >   foo::             ;// ok - foo not fontified (but maybe could be as a
type)
> 
> Is this syntactically valid C++?

Yes, if you ignore the ; (see above).  It makes no difference to
fontification.

> >     foo::bar         // wrong - foo in font-lock-constant-face
> 
> (See above.)
> 
> > The text "foo" in "foo::bar" is fontified in font-lock-constant-face, 
> > rather than font-lock-type-face.  In C++, at least, anything before a 
> > "::" is a namespace or class name.  Note that mis-fontification happens
> > when the "b" of "bar" is typed.
> 
> :-)  The fix, if such is needed, would be to redefine 
> (defconst c-reference-face ...) at cc-fonts.el L145.

Currently, the variable c-reference-face-name is initialised to either
font-lock-reference-face (an alias for font-lock-constant-face which is
documented as to be used for constant and label names) or c-label-face-name
(which resolves to font-lock-label-face, font-lock-constant-face or
font-lock-reference-face).  

It is not documented, but on the face of it, c-reference-face-name suggests
it is not intended to be used for type names.  Am I misunderstanding the
purpose of it?

If you change the value of c-reference-face-name, won't it break other
things that use that face name for constants and labels?

Simon.




reply via email to

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