From xemacs-m  Thu Dec 19 09:58:12 1996
Received: from CNRI.Reston.VA.US (CNRI.Reston.VA.US [132.151.1.1])
          by xemacs.cs.uiuc.edu (8.8.4/8.8.4) with SMTP
	  id JAA08949 for <xemacs-beta@xemacs.org>; Thu, 19 Dec 1996 09:58:12 -0600 (CST)
Received: from newcnri.cnri.reston.va.us by CNRI.Reston.VA.US id aa12319;
          19 Dec 96 10:56 EST
Received: from anthem.CNRI.Reston.Va.US by newcnri.CNRI.Reston.Va.US (SMI-8.6/SMI-SVR4)
	id KAA16920; Thu, 19 Dec 1996 10:56:40 -0500
Received: by anthem.CNRI.Reston.Va.US (SMI-8.6/SMI-SVR4)
	id KAA25480; Thu, 19 Dec 1996 10:56:38 -0500
Date: Thu, 19 Dec 1996 10:56:38 -0500
Message-Id: <199612191556.KAA25480@anthem.CNRI.Reston.Va.US>
From: "Barry A. Warsaw" <bwarsaw@CNRI.Reston.VA.US>
To: Martin Buchholz <mrb@eng.sun.com>
Cc: XEmacs Beta Test <xemacs-beta@xemacs.org>, tor@eng.sun.com
Subject: Re: Should // comments be recognized in C mode?
References: <199612190628.WAA06077@xemacs.eng.sun.com>
Reply-To: "Barry A. Warsaw" <bwarsaw@CNRI.Reston.VA.US>
X-Attribution: BAW
X-Oblique-Strategy: Fill every beat with something
X-WWW-Homepage: http://www.python.org/~bwarsaw


>>>>> "MB" == Martin Buchholz <mrb@Eng.Sun.COM> writes:

    MB> Folks at Sun were complaining that `//' comments in their C++
    MB> header files (.h) were not being recognized as comment
    MB> delimiters.

If these header files really contained C++ code and not C code, then
you need to find a way to make sure that those files are edited in
c++-mode and not c-mode.  The fact that .h is used as a suffix for
both C and C++ means that you need something more intelligent (or
expressive) than auto-mode-alist to make that determination.  I agree
that Emacs cruft in the file (first-line or local-var section) is
disgusting.

    MB> Rather than change auto-mode-alist to set the mode of .h files
    MB> to C++, I discovered after some digging that

    MB> (c-enable-//-in-c-mode)

    MB> does what I want.  Why don't we make this the default?

    MB> Some users will lose because of code like this: double x =
    MB> 1//*divide*/2; but they deserve to lose.

    MB> I checked gcc, and it accepts `//' comments in C code unless
    MB> the -ansi flag is set.

Exactly.  // isn't a comment in ANSI C and I don't want to encourage
sneaking these C++'isms into C code.  I recognize the utility of it so
I'm not prohibiting it obviously; and it's easy enough to call
c-enable-//-in-c-mode in your mode hook.  Note that this causes a
*global* c-mode change BTW, which cannot be made buffer local --
another reason not to like making this the default.

    MB> Barry: In any case, the value of c-C++-comment-start-regexp
    MB> could be defined slightly more efficiently as "/[/*]".

That seems like a decent change... thanks!

-Barry

