all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Jostein Kjønigsen" <jostein@secure.kjonigsen.net>
To: theo@thornhill.no, 43559@debbugs.gnu.org
Cc: acm@muc.de
Subject: bug#43559: 28.0.50; [PATCH] Add csharp support to cc-mode
Date: Tue, 22 Sep 2020 16:26:41 +0200	[thread overview]
Message-ID: <8081dcbd-1e89-c9e6-d691-1270df8f9f19@secure.kjonigsen.net> (raw)
In-Reply-To: <87wo0myn2l.fsf@thornhill.no>

[-- Attachment #1: Type: text/plain, Size: 4819 bytes --]

On 22.09.2020 15:10, Theodor Thornhill wrote:
> Jostein Kjønigsen <jostein@secure.kjonigsen.net> writes:
>
>> Hey Theo.
>>
>> Thanks for your work on trying to get something new, and possibly better
>> C#-support mainlined in Emacs!
> My pleasure - hopefully we'll get there :)
>
> [...]
>
Hey Theo.

I still haven't looked at the code in your patch, but I've applied it to 
latest Emacs Git master, and given it a test-run.

When going over existing code, everything looks and feels nice. And it's 
much faster than my "old", non-transferable code. So I definitely think 
this is a /very good/ start.

While I hold no "position" in GNU or Emacs as a whole, I would consider 
myself a C# veteran (since 2004), and as the old maintainer of old 
csharp-mode, I think I have some experience which may be useful.

So for the time being, I'll just promote myself to being the "critical 
Emacs C#-user", and provide some feedback based on my expectations for 
how editing C# should feel or behave.

Please don't consider the following comments as negative towards your 
work, or me in any way trying to dissuade you from getting this 
mainlined. I'm just here to try to help you ensure that what you land is 
going to be "good enough" so that it will be easier to argue for 
inclusion in core-Emacs later on :)

So with all that said, so far I've noticed a few things which I think 
arguably goes against C# convention, and would be nice to get fixed, if 
possible. There's also a some things where I just feel it would "better" 
to do things differently.

Roughly it boils down to this list:

1. Attributes

2. Object initializers

3. Lambda indentation

4. Misc variables/field fontification issues


*First off: **Attributes are not handled properly. **
*

In java-mode annotations gets fontified and indented properly:

In your current csharp-mode draft, we get no fontification, and we also 
get a trailing indentation bug for the equivalent C# code:

For annotation-heavy frameworks like ASP.Net Core this might get 
annoying. It would be great if this could get fixed.


*Second: Object initializers are not indented properly.*

Consider the following fairly simple case. Using the provided patch we 
get the following indentation:

According to C# convention, one would expect something more like this:

This one is arguably very hard to get right, because it's a conceptually 
infinitely recursive problem. (You may initialize a property with 
another object-initializer.)

While solving this perfectly for all cases is clearly out the window, do 
you think it would be possible at least to make 1-level 
object-initilizers work?

One the bright side /collection-/initializers seems to work just fine :)


*Third: Lamda-function indentation when used with higher order functions
*

Lambdas also suffer from some unexpected indentation issues:

Here I would expect the following indentation instead:


*Fourth: variable-fontification*

Here I have no absolute C# convention to quote for absolute correctness, 
but it kinda "feels wrong" to me at places.

Without a proper language-engine to guide us, it will be literally 
impossible to know what is a class, a namespace, an enum, a local field 
or an actual variable at any point in the code, and fontify the code 
100% correctly based on that.

So we'll have to make due with imperfections, make some pragmatical 
decisions on what we think will be good default/fallback values, and 
that's OK.

Right now though, all implicitly typed variables (vars), local variables 
with method-access and local fields with property-access are shown using 
/font-lock-constant-face/ and that seems a bit off:

For var-heavy functions, this inconsistency is somewhat distracting, and 
I would much prefer a font-lock-variable-face fallback in these cases.

As for "_field" and "foo.", I'm not sure what the best fallback would 
be. Without a language-engine to guide us, this is genuinely hard stuff 
to get right.

By C# convention pascalCased or _underCased identifiers typically 
represent local variables and object-local fields (and thus might use 
font-lock-variable-face as a fallback).

Conversely CamelCased identifiers typically represent either Classes or 
public properties/methods on those, depending on identifier in question 
being dot-accessed or not (and for these another face might make more 
sense).

I'm sure just/discussing/ the///soft-rules/ for these aspects could take 
months alone, not speaking for the effort required to actually making it 
happen in code.

Consider it something to aim for, but I wouldn't expect anyone to get 
this right in a version 1 of anything.


Otherwise, great work, and thank you for putting in this effort!

-- 
Kind regards
*Jostein Kjønigsen*

jostein@kjonigsen.net 🍵 jostein@gmail.com
https://jostein.kjønigsen.no

[-- Attachment #2.1: Type: text/html, Size: 7246 bytes --]

[-- Attachment #2.2: nhebmpbbonkfichd.png --]
[-- Type: image/png, Size: 7374 bytes --]

[-- Attachment #2.3: epihfhegglofbbha.png --]
[-- Type: image/png, Size: 7013 bytes --]

[-- Attachment #2.4: hfhhbebmljemcgca.png --]
[-- Type: image/png, Size: 5608 bytes --]

[-- Attachment #2.5: fiaafecacbkbgbkh.png --]
[-- Type: image/png, Size: 5475 bytes --]

[-- Attachment #2.6: aceilhdglgpjgcad.png --]
[-- Type: image/png, Size: 5913 bytes --]

[-- Attachment #2.7: mehgknkpcccjilmm.png --]
[-- Type: image/png, Size: 6620 bytes --]

[-- Attachment #2.8: jognflfdjkamkonl.png --]
[-- Type: image/png, Size: 6622 bytes --]

[-- Attachment #2.9: igcegelpjofikpgg.png --]
[-- Type: image/png, Size: 19080 bytes --]

  reply	other threads:[~2020-09-22 14:26 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 [this message]
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
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=8081dcbd-1e89-c9e6-d691-1270df8f9f19@secure.kjonigsen.net \
    --to=jostein@secure.kjonigsen.net \
    --cc=43559@debbugs.gnu.org \
    --cc=acm@muc.de \
    --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.