unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org
Subject: Re: FW: Font-lock misfontifies foo::bar in C++
Date: Wed, 16 Aug 2006 12:47:01 +0100	[thread overview]
Message-ID: <20060816114701.GB1509@muc.de> (raw)
In-Reply-To: <81CCA6588E60BB42BE68BD029ED4826009152E0B@wimex2.wim.midas-kapiti.com>

Morning, Simon!

On Mon, Aug 07, 2006 at 09:32:59AM +0100, Marshall, Simon wrote:
> > > 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).

#########################################################################

OK.  Just to clarify where I think we are - In this:

    void foo::bar()

, "foo" gets font-lock-constant-face.

(i) We both agree that this face assignment is deliberate and
  documented: On the page "Faces" in the CC Mode manual, it says:
  * Name qualifiers and identifiers for scope constructs are
    fontified like labels.
  * Label identifiers get `font-lock-constant-face' if it exists,
    `font-lock-reference-face' otherwise.
(ii) You're saying that fontifying "foo::" like a label is bad.

#########################################################################

> > 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?

I'm at a disadvantage here, because I don't feel at all strongly about
what the right face is for "foo::", as long as it's visually distinct.
In fact I'd never really noticed that it was font-lock-constant-face.

You're an expert on font-lock, though.  Why would f-l-type-face be any
better?  Martin feels quite strongly, that "foo::bar" is not using foo
"in a type context", and has referred to Pike (one of CC Mode's other
languages), where a constant declaration is a special case of a class
declaration.

> 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?

OK; maybe.  But that would definitely be a new feature for CC Mode 5.32,
not something to slip in to 5.31.n in a hurry.

As regards f-l-constant-face on "foo::":  I don't really want to change
it, since this would be a lot of work.  Changing the code in cc-fonts.el
and the text in the manual would be relatively quick and easy, but then
I'd have to update the regression test program 000tests.el, and
recalcuate all the "face files" in the test suite, diff them with the
existing versions, and commit them to the CVS repository.  There are 166
files.face involved.  I would surely also get complaints from people
who've got used to the existing fontification.

So why is f-l-constant-face so jarring here?  I can see that it's not
particularly appropriate, but what is there about it that makes it
repulsive and ghastly, that raises a calm competent hacker's hackles?
(This isn't a rhetorical question.) 

> I'm not on either mailing list, so please CC: me on any reply.

Not merely a CC, but a To: is what you get.  :-)

> Thanks, Simon.

-- 
Alan.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


  reply	other threads:[~2006-08-16 11:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-07  8:32 FW: Font-lock misfontifies foo::bar in C++ Marshall, Simon
2006-08-16 11:47 ` Alan Mackenzie [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-08-16 14:35 Marshall, Simon
2006-07-25  8:48 Marshall, Simon
2006-08-06 18:08 ` Alan Mackenzie
     [not found] <81CCA6588E60BB42BE68BD029ED48260089A94BF@wimex2.wim.midas-kapiti.com>
2006-07-24 18:27 ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060816114701.GB1509@muc.de \
    --to=acm@muc.de \
    --cc=bug-cc-mode@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).