From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Alan Mackenzie <acm@muc.de>
Cc: 43559@debbugs.gnu.org, jostein@kjonigsen.net
Subject: bug#43559: 28.0.50; [PATCH] Add csharp support to cc-mode
Date: Mon, 28 Sep 2020 21:52:00 +0200 [thread overview]
Message-ID: <87ft714r33.fsf@thornhill.no> (raw)
In-Reply-To: <20200923101150.GB6178@ACM>
Hello, Alan!
Alan Mackenzie <acm@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
next prev parent reply other threads:[~2020-09-28 19:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-22 10:37 bug#43559: 28.0.50; [PATCH] Add csharp support to cc-mode Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-22 12:51 ` Jostein Kjønigsen
2020-09-22 13:10 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-22 14:26 ` Jostein Kjønigsen
2020-09-22 21:15 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-23 8:46 ` Jostein Kjønigsen
2020-09-23 10:11 ` Alan Mackenzie
2020-09-23 18:38 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-28 19:52 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-07-21 12:19 ` Lars Ingebrigtsen
2021-07-21 12:36 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-07-21 12:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-07-21 13:18 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
[not found] ` <jwvim13zo90.fsf-monnier+emacs@gnu.org>
[not found] ` <35791e76-b783-4856-a4e4-adf7996b5a45@www.fastmail.com>
[not found] ` <jwv5yx3zisf.fsf-monnier+emacs@gnu.org>
[not found] ` <jwvsg07y0jc.fsf-monnier+emacs@gnu.org>
[not found] ` <m1a6mf4fs0.fsf@Frende-MacBook.lan>
[not found] ` <jwvtuknwi87.fsf-monnier+emacs@gnu.org>
[not found] ` <m17dhj4bwo.fsf@Frende-MacBook.lan>
[not found] ` <jwvh7gkrcrw.fsf-monnier+emacs@gnu.org>
[not found] ` <m1mtpcouwb.fsf@Frende-MacBook.lan>
[not found] ` <jwveeamohsz.fsf-monnier+emacs@gnu.org>
[not found] ` <325FA529-DED9-4061-8536-39168D18A504@thornhill.no>
2021-08-25 16:07 ` Lars Ingebrigtsen
2021-07-21 14:05 ` Jostein Kjønigsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ft714r33.fsf@thornhill.no \
--to=bug-gnu-emacs@gnu.org \
--cc=43559@debbugs.gnu.org \
--cc=acm@muc.de \
--cc=jostein@kjonigsen.net \
--cc=theo@thornhill.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.