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: Mon, 28 Sep 2020 21:52:00 +0200 Message-ID: <87ft714r33.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="8561"; 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 Mon Sep 28 21:54:13 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 1kMzDw-00025n-GH for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Sep 2020 21:54:12 +0200 Original-Received: from localhost ([::1]:48634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMzDv-0002BR-J4 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Sep 2020 15:54:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kMzDn-0002AM-9E for bug-gnu-emacs@gnu.org; Mon, 28 Sep 2020 15:54:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kMzDm-0004wY-Vx for bug-gnu-emacs@gnu.org; Mon, 28 Sep 2020 15:54:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kMzDm-0002rC-WF for bug-gnu-emacs@gnu.org; Mon, 28 Sep 2020 15:54:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Sep 2020 19:54:02 +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.160132278210884 (code B ref 43559); Mon, 28 Sep 2020 19:54:02 +0000 Original-Received: (at 43559) by debbugs.gnu.org; 28 Sep 2020 19:53:02 +0000 Original-Received: from localhost ([127.0.0.1]:54063 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzCo-0002pQ-Ai for submit@debbugs.gnu.org; Mon, 28 Sep 2020 15:53:02 -0400 Original-Received: from out1.migadu.com ([91.121.223.63]:12736) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzCl-0002ow-0M for 43559@debbugs.gnu.org; Mon, 28 Sep 2020 15:53:01 -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=1601322777; 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=Ftugfl6e8+cXsWSTmKFLxLQC4nnSq2UjhZQKjxabtxY=; b=X5fTc1wMl4ayqVJeBoBJcEtTBZIHELy9xe5NvmGw54ywo6CKvRg4bPYMZaws9P95K8xM9K DFyuFtwto40t+TPWS187TZ7iU/thiFFPDv7efFzludfZiOhKQHX4nV4POHafgoymFRj05f bzCpjBLeyOq0fGWIrqYNKRok0CKJCXrZ4kndf64yQWqsAvWRPai7Wn8WOCSKl3NeOcWhMO 9YSki06hIQs9Y6oLfUFqoIRgntHxEeIt5mUMB4mr3Du/bZwrmMQi14NpbuKj3/f8SOeEve ZmC2t8V5tHEyyVIrCSqSkM6BMoUUydg608P4iYYC5inHyGb2WXj2wp9/7pB8IA== 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:189224 Archived-At: Hello, Alan! Alan Mackenzie writes: [...] > > I don't see a reason why there shouldn't be a C# Mode directly in Emacs. > The current csharp mode is now rewritten, and I've gotten almost everything to work nicely apart from one issue, and I was hoping that you could help me figure it out, or point me in the right direction. I described it here: https://lists.gnu.org/archive/html/emacs-devel/2020-09/msg01975.html However, The lambda case is now fixed, but with a patch to emacs itself: -------------------------------------------------------------------------------- diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 4e336c0a06..b415e4b821 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -12011,7 +12011,8 @@ c-looking-at-inexpr-block (> (point) closest-lim)) (not (bobp)) (progn (backward-char) - (looking-at "[]).]\\|\\w\\|\\s_")) + (or (looking-at "[\]\).]\\|\w\\|\\s_") + (looking-at ">"))) (c-safe (forward-char) (goto-char (scan-sexps (point) -1)))) @@ -12085,7 +12086,11 @@ c-looking-at-inexpr-block (setq passed-bracket-pairs 1) (setq bracket-pos (point)))) 'maybe) - 'maybe)))) + 'maybe) + (if (or (looking-at "([[:alnum:][:space:]_,]*)[ \t\n]*=>[ \t\n]*{") + (looking-at "[[:alnum:]_]+[ \t\n]*=>[ \t\n]*{")) + ;; If we are at a C# lambda header + (cons 'inexpr (point)))))) (if (eq res 'maybe) (cond -------------------------------------------------------------------------------- This patch lets CC Mode detect the lambda case for C#. I know this is a patch specific to C#, but I could not find anywhere or anyhow this would work without these lines. With them, the indentation in case 1 in the mentioned link works perfectly. Maybe this (or something similar) could be eligible for inclusion in CC Mode, to account for that lambda syntax. I know many other C-like languages uses similar syntax, so I believe it could be useful for someone else as well. Have a nice evening! -- Theodor Thornhill