emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CC Mode lambda function help


From: Alan Mackenzie
Subject: Re: CC Mode lambda function help
Date: Fri, 9 Oct 2020 10:57:03 +0000

Hello, Theodor.

I just noticed your post from a fortnight ago.  Sorry I didn't notice it
earlier.

On Fri, Sep 25, 2020 at 23:05:42 +0200, Theodor Thornhill wrote:

> Hello!

> I am reworking the csharp mode found at
> https://github.com/josteink/csharp-mode, and I have some problems I am
> really struggling to fix, or find information about in the manual (if
> it is there):

OK.  Version numbers?  ;-)

What does "the" manual mean?  If it doesn't mean the CC Mode manual,
then it should.  It's available in .../emacs/info/ccmode.info, or
some very similar address.  It contains a wealth of information, being
largely written by myself.  :-)

> 1. Lambda functions

> Consider this code:

> ```
> AsyncTest.Run(async () =>
> {
>     Something xyz =
>         new SomethingMore();
> });
> ```

> Right now this indents as:
> ```
> AsyncTest.Run(async () =>
>               {
>                   Something xyz =
>                   new SomethingMore();
>               });
> ```
> I cannot find what c-lang-defconst to configure, or what c-style-alist
> combination to pick to get this.  Any pointer to what is wrong would be
> super helpful.

OK, just to be quite clear, c-lang-defconsts are intended for the use of
hackers maintaining CC Mode or modes derived from it (as you are doing),
to specify modes.  They are not for users' configuration, for which see
things like "styles" and c-offsets-alist and other things in the
configuration section of the CC Mode manual.

I think it likely you have run into a configuration bug, possibly an old
bug, where a "syntactic offset" was inappropriately set.  To see the
syntactic symbol(s) for a source line, put point on it and do C-c C-s.
To see the offset currently configured for that/those symbol(s), do C-c
C-o (again, see the CC Mode manual for any needed explanations).

Running the CC Mode head on Emacs master, I don't see the problems
you're having.  But I haven't yet downloaded the branch from github that
you mention.

> 2. Attributes

> Consider this code:

> ```
> [DllImport("something.dll")]
> public extern int GetSomething();

> ```

> Gets indented as:
> ```
> [DllImport("something.dll")]
>     public extern int GetSomething();
> ```

> This I attribute (pun intended) to vsemi, since when one is added:
> ```
> [DllImport("something.dll")];  // <-- notice this
> public extern int GetSomething();
> ```

> It behaves correctly. In addition, that semi fixes fontification for the
> method name. I would like not to use the 'statement-cont', since that
> only looks like a symptom, rather than a fix.

> I'd love some pointers to how I would best handle this. 

I think you know the answer: fix csharp--at-vsemi-p.  It seems intended
to detect the attribute in square brackets and signal a virtual
semicolon.  Why is it not working?

> To reproduce this, you have to (unfortunately...) clone the
> abovementioned repo, checkout the 'rework' branch, then byte compile
> that file.  I am sorry there is no quicker way to get to that code.

> These snippets should be enough to illustrate my issues.

I hope this answer from me is at least somewhat helpful.

> Have a lovely day,

Yourself, too!

> Theodor Thornhill

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]