From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: RFR cc-langs.el: change syntax for @ in Java Date: Mon, 12 Apr 2021 13:36:07 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39302"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Apr 12 15:36:58 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lVwkM-000A7F-6p for ged-emacs-devel@m.gmane-mx.org; Mon, 12 Apr 2021 15:36:58 +0200 Original-Received: from localhost ([::1]:33036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lVwkL-0001TG-89 for ged-emacs-devel@m.gmane-mx.org; Mon, 12 Apr 2021 09:36:57 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVwjj-00013W-Gm for emacs-devel@gnu.org; Mon, 12 Apr 2021 09:36:19 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:21025 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1lVwjc-0007En-3Q for emacs-devel@gnu.org; Mon, 12 Apr 2021 09:36:19 -0400 Original-Received: (qmail 17600 invoked by uid 3782); 12 Apr 2021 13:36:07 -0000 Original-Received: from acm.muc.de (p4fe15ca4.dip0.t-ipconnect.de [79.225.92.164]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 12 Apr 2021 15:36:07 +0200 Original-Received: (qmail 7556 invoked by uid 1000); 12 Apr 2021 13:36:07 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:267961 Archived-At: Hello, Filipp. On Thu, Apr 08, 2021 at 20:26:49 +0300, Filipp Gunbin wrote: > Hi Alan, > On 08/04/2021 10:15 +0000, Alan Mackenzie wrote: > > I've just run the CC Mode test suite with this amendment, and it > > produces the following successes on annotations-1.java: > > annotations-1.java:4: Expected analysis ((inclass 1) (topmost-intro 21)), got ((inclass 21) (topmost-intro 21)) > > annotations-1.java:4: Expected indentation 0, got 32 > > annotations-1.java:5: Expected analysis ((class-close 1)), got ((class-close 21)) > > .. So, there are things to sort out before we can apply the change. > I think these breakages are not real breakages, but rather the resfile > could be updated. I've had a more thorough look at it. In cc-langs.el, there are several places where @ is treated as a symbol character, namely: L375: c-make-mode-syntax-table (which you have proposed modifying) L419: c-identifier-syntax-modifications L636: c-symbol-start L1969: c-paragraph-start (I think this one only applies in comments) L2198: c-class-decl-kwds (The "@interface" keyword) We need to consider whether to amend some or all of these places, so that @ ceases to be a (starting) character of an identifier. I'm also a bit worried that in @NonNull @TestClass @FooBar public class Annotations { , the last line gets parsed as ((annotation-top-cont 21)), where it really ought to be a topmost-intro. But this problem is present without your patch, anyway. In summary, I think the motivation for the change (highlighting symbols correctly) is valid, but the change is going to be more involved than the patch you've supplied. Do you want to look at all these things, or should I? > This class: > --8<---------------cut here---------------start------------->8--- > @NonNull > @TestClass > @FooBar public class Annotations { > } > --8<---------------cut here---------------end--------------->8--- > previosly "started" at the @NonNull line, but now "starts" at @FooBar > line, which is absolutely correct. Are you saying here that @FooBar is actually a part of the declaration of class Annotations? If so, why not @NonNull and @TestClass as well? > So here's the updated patch (now against the cc-mode repo). > Thanks. Thank you! > diff -r 10abd4587dad cc-langs.el > --- a/cc-langs.el Mon Mar 29 15:20:53 2021 +0000 > +++ b/cc-langs.el Thu Apr 08 20:22:56 2021 +0300 > @@ -365,12 +365,14 @@ > (let ((table (make-syntax-table))) > (c-populate-syntax-table table) > ;; Mode specific syntaxes. > - ,(cond ((or (c-major-mode-is 'objc-mode) (c-major-mode-is 'java-mode)) > + ,(cond ((c-major-mode-is 'objc-mode) > ;; Let '@' be part of symbols in ObjC to cope with > ;; its compiler directives as single keyword tokens. > ;; This is then necessary since it's assumed that > ;; every keyword is a single symbol. > `(modify-syntax-entry ?@ "_" table)) > + ((c-major-mode-is 'java-mode) > + `(modify-syntax-entry ?@ "'" table)) > ((c-major-mode-is 'pike-mode) > `(modify-syntax-entry ?@ "." table))) > table))) > diff -r 10abd4587dad tests/annotations-1.res > --- a/tests/annotations-1.res Mon Mar 29 15:20:53 2021 +0000 > +++ b/tests/annotations-1.res Thu Apr 08 20:22:56 2021 +0300 > @@ -1,8 +1,8 @@ > ((topmost-intro <0,0>)) > ((annotation-top-cont <1,0>)) > ((annotation-top-cont <1,0>)) > -((inclass <3,0>) (topmost-intro <1,0>)) > -((class-close <4,0>)) > +((inclass <1,0>) (topmost-intro <1,0>)) > +((class-close <2,0>)) > ((topmost-intro <1,0>)) > ((topmost-intro <2,0>)) > ((inclass <1,0>) (topmost-intro <1,0>)) -- Alan Mackenzie (Nuremberg, Germany).