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.bugs Subject: bug#43559: 28.0.50; [PATCH] Add csharp support to cc-mode Date: Wed, 23 Sep 2020 10:11:50 +0000 Message-ID: <20200923101150.GB6178@ACM> References: <87zh5iyu4d.fsf@thornhill.no> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29523"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 43559@debbugs.gnu.org, jostein@kjonigsen.net To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 23 12:13:10 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1kL1lu-0007Yb-It for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 23 Sep 2020 12:13:10 +0200 Original-Received: from localhost ([::1]:38854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kL1lt-0001gq-Cp for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 23 Sep 2020 06:13:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kL1lm-0001gc-I9 for bug-gnu-emacs@gnu.org; Wed, 23 Sep 2020 06:13:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51294) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kL1lm-0002aT-7Q for bug-gnu-emacs@gnu.org; Wed, 23 Sep 2020 06:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kL1lm-0002cV-0b for bug-gnu-emacs@gnu.org; Wed, 23 Sep 2020 06:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 23 Sep 2020 10:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43559 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 43559-submit@debbugs.gnu.org id=B43559.16008559229938 (code B ref 43559); Wed, 23 Sep 2020 10:13:01 +0000 Original-Received: (at 43559) by debbugs.gnu.org; 23 Sep 2020 10:12:02 +0000 Original-Received: from localhost ([127.0.0.1]:34605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kL1kn-0002aA-J1 for submit@debbugs.gnu.org; Wed, 23 Sep 2020 06:12:01 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:11674 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1kL1kk-0002Zh-H6 for 43559@debbugs.gnu.org; Wed, 23 Sep 2020 06:12:00 -0400 Original-Received: (qmail 77029 invoked by uid 3782); 23 Sep 2020 10:11:51 -0000 Original-Received: from acm.muc.de (p4fe156c4.dip0.t-ipconnect.de [79.225.86.196]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Wed, 23 Sep 2020 12:11:51 +0200 Original-Received: (qmail 6535 invoked by uid 1000); 23 Sep 2020 10:11:50 -0000 Content-Disposition: inline In-Reply-To: <87zh5iyu4d.fsf@thornhill.no> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:188770 Archived-At: Hello, Theodor. On Tue, Sep 22, 2020 at 12:37:54 +0200, Theodor Thornhill wrote: > Hello! > For some time, I've been a little dissatisfied with the support for C# > in emacs. Recently, there has been some breakage in handling of strings > and fontification, more precisely: > - https://github.com/josteink/csharp-mode/issues/128 The current C# mode uses syntax-propertize-function. This clashes nastily with CC Mode's use of the syntax-table text property. When syntax-propertize-function is non-nil, Emacs arbitrarily wipes all syntax-table properties from a region then relies on s-p-f to reapply all the necessary s-t properties. However the current C# s-p-f only applies a restricted subset of the necessary properties. This will produce random bugs. The documentation for syntax-propertize-function didn't used to mention this problem, but it does now. (As from Emacs 27.2). The method used in CC Mode to apply and remove these properties is to add functions, effectively before- or after-change-functions, to either or both of c-get-state-before-change-functions and c-before-font-lock-functions. > Also, it is using a lot of internal c-mode functions: > - https://github.com/josteink/csharp-mode/issues/153 > I've had some discussions with with the current maintainer, Jostein > Kjønigsen (cc'd) about the future of this mode in > https://github.com/josteink/csharp-mode/issues/162. > Some points of note: > - It cannot easily be donated to emacs due to paperwork > - Jostein does not have time to do it himself > - I took upon myself to rewrite it in a separate branch, as an end > goal for it to be included in emacs > While working on this, I realized the easiest way to get something good > here is to overall reduce the complexity. As such I created this patch. CC Mode places a high priority on correctness, hence much of its complexity. That priority needn't necessarily be carried over to derived modes. ;-) > It seems to work nicely, removing the need for the external mode > completely. You're proposing integrating a new C# Mode directly into CC Mode. This goes against CC Mode policy, both because it would swell the already massive code base, and it would increases the danger of "orphan" submodes. We already have IDL Mode and Pike Mode which have remained entirely and almost entirely unchanged in the last 15 years. The people who created them are no longer around. Also, there is no advantage for an integrated mode over a derived mode separate from CC Mode. (If there is, that is a bug in CC Mode. ;-) There is a slight effort in using c-add-language, that is all. > However, I see that including csharp here is most likely a bigger effort > than just sending this patch, but I wanted to send what I have, and > hopefully get some pointers. Or in worst case stop before I go too > far.. I don't see a reason why there shouldn't be a C# Mode directly in Emacs. > This patch is written without consulting the current mode, so paperwork > should not be an issue. > In addition, the current mode has an implementation of imenu rewritten > from scratch by Jostein, and as such I think this can be included as > well. > I tried not to do too much, since I believe most of the advanced > functionality should be provided by an lsp mode such as eglot or lsp-mode. That is a completely different topic. The amount of work needed to use one of these is massive. For what it's worth, somebody familiar with LSPs opined that they weren't yet sufficiently mature to support something like CC Mode, but this was some while ago (between 1 and 2 years ago). > Have a nice day! > Theodor Thornhill [ Patch snipped, but briefly scanned. ] -- Alan Mackenzie (Nuremberg, Germany).