From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: first-class support for csharp in cc-mode.el Date: Wed, 30 Dec 2009 21:01:00 +0000 Message-ID: <20091230210100.GB2247@muc.de> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1262206519 19635 80.91.229.12 (30 Dec 2009 20:55:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 30 Dec 2009 20:55:19 +0000 (UTC) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: dino chiesa Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 30 21:55:12 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NQ5ZX-0002nW-Gi for ged-emacs-devel@m.gmane.org; Wed, 30 Dec 2009 21:55:11 +0100 Original-Received: from localhost ([127.0.0.1]:55517 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQ5ZX-0005xM-V6 for ged-emacs-devel@m.gmane.org; Wed, 30 Dec 2009 15:55:12 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NQ5ZS-0005v1-A7 for emacs-devel@gnu.org; Wed, 30 Dec 2009 15:55:06 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NQ5ZN-0005rv-Qo for emacs-devel@gnu.org; Wed, 30 Dec 2009 15:55:06 -0500 Original-Received: from [199.232.76.173] (port=33031 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQ5ZN-0005rs-Ka for emacs-devel@gnu.org; Wed, 30 Dec 2009 15:55:01 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:2800 helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NQ5ZM-00019Q-SL for emacs-devel@gnu.org; Wed, 30 Dec 2009 15:55:01 -0500 Original-Received: (qmail 53288 invoked by uid 3782); 30 Dec 2009 20:54:55 -0000 Original-Received: from acm.muc.de (pD9E53105.dip.t-dialin.net [217.229.49.5]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Wed, 30 Dec 2009 21:54:54 +0100 Original-Received: (qmail 2816 invoked by uid 1000); 30 Dec 2009 21:01:00 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-operating-system: by monty-python.gnu.org: FreeBSD 4.6-4.9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:119073 Archived-At: Hi, Dino, On Wed, Dec 30, 2009 at 08:29:14AM -0800, dino chiesa wrote: > Hi Alan, nice to meet you. > Stefan, thanks for the input. > acm@muc.de wrote: > > The current policy is not to add any more languages to the core of CC > > Mode, since it's hassle enough supporting the seven that are already > > there. There are certainly lots of users of C, C++, Java, several > > users of Objective C and AWK, but I just don't know about Pike and > > IDL. The problem is, when somebody implements support for a language > > directly in CC Mode and they move on a few years later, support for > > that langauge effectively vanishes. It was to fix this that Martin > > Stjernholm (my predecessor) implemented the c-lang-const mechanism. > Very clear. In that case I should be petitioning to get csharp-mode put > into the emacs progmodes distrib separately, rather than petitioning to > get csharp-mode folded into cc-mode. I think so. I doubt Stefan will take that much persuading. ;-) > > If the c-lang-const stuff is inadequate to support, say, C#, then I > > would prefer to amend CC Mode so that C# can be supported. It looks > > like the @"....." syntax will need such an amendment. This will > > probably involve a large change, since the use of \ as an escape > > character is firmly embedded in the very fabric of CC Mode. Is @ used > > for anything else in C#? Is it forbidden to have whitespace between @ > > and "? > Yes, according to the lang spec, the @ must immediately be followed by > a double-quote. The symbol is not used for anything else in the > language. I just looked and this is called a "verbatim string literal". > http://www.go-mono.com/docs/index.aspx?link=ecmaspec%3a9.4.4.5 > > In fact, I've just thought of a way of fixing this: in an > > after-change function, splat the syntax (using syntax-table > > text-properties) of anything within @"....". I think there's already > > a suitable hook in CC Mode for this. I've had a look at this. The two hooks you want are c-get-state-before-change-function and c-before-font-lock-function, both of which are c-lang-defconsts. In the function you put in the first hook, you should see whether or not you're about to disrupt the status of one or more @"......\" constructs. There'll be some cunning special cases to check here. The function on the second hook will actually add the text-property to the pertinent \, or possibly remove it. > Is this the approach used for handling of slashes within awk? (can be > either a divide operator or a string delimiter). I tried wading through > that code but didn't yet figure it out. :-) I wrote that code some while ago, and I'm not sure I could figure it out any more. It's a fairly involved finite state machine implemented by regular expressions. > In csharp, it is not only a trailing slash that is special - the > verbatim string also allows verbatim newlines in the string. This is > legal: > var s = @"The quick brown fox > jumps over the lazy dog"; > and results in a string with a \n between the 4th and 5th words. > I don't know how that might affect the final design of a solution, or > if it recommends or disrecommends Stefan's suggestion to worry only > about the final slash. I couldn't say off-hand either. I suspect it would just work. > >> I have no idea if this is a friendly proposal or not, but it would > >> make things nice for people who write C# and use emacs. > > Thanks for the proposal! Constructive suggestions are always welcome at > > CC Mode. By the way, CC Mode has its own mailing list at > > bug-cc-mode@gnu.org and is hosted on sourceforge for historical reasons. > Ah, very good. Is bug-cc-mode intended to serve discussion related only > to bugs or potential bugs, or is it also good for random discussion or > questions from cc-derived modes? I mean, if I were to ask specifically > about the verbatim string literals, should I ask on emacs-devel or is > it better on bug-cc-mode ? Probably better on bug-cc-mode, but more people will see it on emacs-devel. > >> There are still a few issues with that C# mode - lambdas have no > >> special support, and the new dynamic keyword in .NET 4.0 isn't there > >> (simple to add), and there is the literal string thing I described > >> in my other mail thread - but mostly it works well. Including this > >> would provide a good baseline of support in emacs for C#. > > Those are all issues for C# Mode's maintainer. > Right, those are issues for me (and friends) to own. I wasn't really > asking for *that*, although I may ask for specific advice on some of > those in the future, after I take a run at them, I hope you don't mind. > My real goal regarding "first class support" is to make csharp-mode > official and standard, so that someone downloading emacs 24 or 23.x > will just get it. I had originally thought that meant major surgery on > cc-mode, but you're telling me it could be simpler than that. It should be, and if it's not, I should be able to make it so. -- Alan Mackenzie (Nuremberg, Germany).