From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#43559: 28.0.50; [PATCH] Add csharp support to cc-mode Date: Wed, 23 Sep 2020 20:38:22 +0200 Message-ID: <87o8lw49up.fsf@thornhill.no> References: <87zh5iyu4d.fsf@thornhill.no> <20200923101150.GB6178@ACM> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5642"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 43559@debbugs.gnu.org, jostein@kjonigsen.net To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 23 20:44:50 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 1kL9l3-0001IN-SM for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 23 Sep 2020 20:44:50 +0200 Original-Received: from localhost ([::1]:56956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kL9l2-0003cR-Ta for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 23 Sep 2020 14:44:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kL9fS-0006FC-At for bug-gnu-emacs@gnu.org; Wed, 23 Sep 2020 14:39:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54523) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kL9fR-0001mr-Vi for bug-gnu-emacs@gnu.org; Wed, 23 Sep 2020 14:39:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kL9fR-0006Hu-Ts for bug-gnu-emacs@gnu.org; Wed, 23 Sep 2020 14:39:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 23 Sep 2020 18:39: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.160088630824110 (code B ref 43559); Wed, 23 Sep 2020 18:39:01 +0000 Original-Received: (at 43559) by debbugs.gnu.org; 23 Sep 2020 18:38:28 +0000 Original-Received: from localhost ([127.0.0.1]:37836 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kL9eu-0006Gm-86 for submit@debbugs.gnu.org; Wed, 23 Sep 2020 14:38:28 -0400 Original-Received: from out0.migadu.com ([94.23.1.103]:61826) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kL9ep-0006GU-GQ for 43559@debbugs.gnu.org; Wed, 23 Sep 2020 14:38:26 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1600886301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=b5GJ15hYEzwnzoluGHN5m+Ut3IYPvtEKYb6sh5xdGnI=; b=Uzej1GoRi7sROIcgzRzfPifcP6TKWxLrn4X5Rfei34RpkfhJKwEod4GXMzEVK+Vnvj9+wx OrJcchr43vQVVGC4vVH6AOjdy1g4KB/87SiTmNSNy0tKUG8BPvSiEr64UMJ9H8aD726/2v nDNUSjOgQzY81aBVSlX/t1HVexFXiGzSDLN+AGuhxEvqLMyPCWUsTyxzhan2D6jzxgoGHq E+VVqz3xHS7c0J/9ZP/Mhz0UqyqAuBgcWrsuBpbx9jVxZu/xekne3ynA7FRawDTtiZCIl2 +VweD54Ms0cttdgV5xjeHSV9vSobGH17ssDHCzD35SxaF/unnkBUVnSRW3TS8A== In-Reply-To: <20200923101150.GB6178@ACM> 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:188818 Archived-At: Alan Mackenzie writes: > Hello, Theodor. > Hello, and thanks for responding! > 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. Thanks for this information. It will help me investigate further. > > 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. > [...] >> 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. ;-) > Hehe, yeah - it is my hope to leverage more what is already there. >> 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. I see your point here. I guess I wrongly assumed this should be the main way to include new cc-mode based modes. > > 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. > That is good to hear. I guess I'll try to reimplement this patch using this api, rather than convince you to pollute CC Mode. >> 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. > Good. I'll start working on csharp-mode.el, rather than integrating things. >> 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). Yeah, I wasn't really suggesting to integrate CC Mode with eglot. I was merely commenting on reducing the scope of this potential mode. Thanks for taking your time so far. I think I'll for the time being leave this bug, take it back to github, and create a standalone mode. (@Jostein - I'll respond to your comments on GitHub) Have a nice day/evening, -- Theodor Thornhill