[Top][All Lists]
[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: |
Mon, 7 Aug 2006 09:32:59 +0100 |
> > Martin, can you shed any light upon why "foo" in "foo::bar" is given
> > c-reference-face-name?
>
> Sure. "foo" doesn't get the type face since it isn't used as
> a type - it's used as an identifier qualifier. Note that
> "foo" in a "foo::bar"
> expression can be a namespace name too, which isn't a type at all.
Alan, I already explained that it was either a type name or a namespace
name.
My point was that it definitely is *not* a reference (a constant or label).
> Example 3:
>
> foo::bar
>
> "foo" doesn't specify the type of anything here either. Its
> use is to tell in which scope "bar" is declared. Hence it
> gets a face that is different from the type face. I call this
> use "identifier qualifier".
>
> To make this more obvious/precise, you could perhaps
> introduce another face name variable, say
> c-qualifier-face-name, and make a suitable mapping of it onto
> one of the existing font-lock faces. I don't think it should
> be mapped to the type face though, because it would be used
> for namespace names too. In lack of better alternatives I
> chose to map it as I did.
I think c-qualifier-face-name would be a good idea, but I think it odd to
pick a face for its value that is definitely wrong. References are used for
constants and labels. Why not pick a face that is usually right, eg, the
type face?
Perhaps a better solution would be to add a c++-font-lock-extra-qualifiers,
akin to c++-font-lock-extra-types, that is a list of qualifier names. I
would suggest that, by default, these could be fontified in
font-lock-type-face, but perhaps you might like to add a
font-lock-qualifier-face to allow users (or modes) to specify what they
want. For C++, this variable could default to '("std") or somesuch.
So, by default, "foo::bar" would not cause "foo" to be fontified in any
face. If the user wanted it to be fontified, they would modify
c++-font-lock-extra-types if it were a type or
c++-font-lock-extra-qualifiers if it were a namespace.
WDYT? I'm not on either mailing list, so please CC: me on any reply.
Thanks, Simon.