GNU bug report logs - #43559
28.0.50; [PATCH] Add csharp support to cc-mode

Previous Next

Package: emacs;

Reported by: Theodor Thornhill <theo <at> thornhill.no>

Date: Tue, 22 Sep 2020 10:39:02 UTC

Severity: normal

Found in version 28.0.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #29 received at 43559 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 43559 <at> debbugs.gnu.org, jostein <at> kjonigsen.net
Subject: Re: 28.0.50; [PATCH] Add csharp support to cc-mode
Date: Mon, 28 Sep 2020 21:52:00 +0200
Hello, Alan!

Alan Mackenzie <acm <at> muc.de> 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




This bug report was last modified 3 years and 265 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.