emacs-devel
[Top][All Lists]
Advanced

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

Re: Missing features in c-ts-mode


From: Ergus
Subject: Re: Missing features in c-ts-mode
Date: Fri, 17 Feb 2023 09:29:35 +0100

Hi Theodor:

Sorry to bother, but I have a question about commit:

f1f571e Add electric indent for preproc directives

c-mode had by default the [0] indentation for #preprocesor directives,
but there are some use cases where that behavior is not desired (i.e
#pragma).

Actually there are even multi-line pragmas when using OpenMP

int main()
{
    #pragma parallel for first private(x) \
        shared(y) etc
    for (...) {
        ....
    }
}

In this case the pragma in column zero is very confusing. Alan added a
new mode (c-toggle-cpp-indent-to-body) which worked around this issue a
few years ago. I don't if it is possible to enable similar behavior with
your change? Is is?

Best,
Ergus




On Thu, Feb 16, 2023 at 08:14:26PM +0100, Theodor Thornhill wrote:
Theodor Thornhill <theo@thornhill.no> writes:

Eli Zaretskii <eliz@gnu.org> writes:

From: Theodor Thornhill <theo@thornhill.no>
Cc: casouri@gmail.com, emacs-devel@gnu.org
Date: Wed, 15 Feb 2023 20:31:33 +0100

This patch adds some support for this- but I'm not really satisfied yet.
It will electrically indent if you've typed "#i", or if you insert "#"
before say, "if".  The reason it behaves this way right now is that the
parser returns an (ERROR (ERROR)) node when only # is inserted.  I'll
see if I can find some workaround for it.

Thank you for working on this.

Now done.  I believe the fix was small enough to go to emacs-29, so just
pushed.  What would be the best way to create a test that would emulate
this behavior?

I tried

```
Code:
 (lambda ()
   (c-ts-mode)
   (self-insert-command 1 "#"))

Point-Char: |

Name: Electric pound indents to column 0

=-=
int
main (void)
{
 |
 return 0;
}
=-=
int
main (void)
{
#|
 return 0;
}
=-=-=
```

But that didn't run the electric indent afaict.

Theo



reply via email to

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