GNU bug report logs - #61578
30.0.50; c-ts-mode feature request intendation pragmas

Previous Next

Package: emacs;

Reported by: Ergus <spacibba <at> aol.com>

Date: Fri, 17 Feb 2023 17:03:02 UTC

Severity: wishlist

Found in version 30.0.50

Full log


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

From: Ergus <spacibba <at> aol.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; c-ts-mode feature request intendation pragmas
Date: Fri, 17 Feb 2023 18:01:44 +0100
This is a feature request related with:

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 and similes:

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

     #pragma omp parallel
     {
        #pragma omp task
        {
         ...
        }
        #pragma omp taskwait
     }
}

In these cases the pragma in column zero will very confusing.

Some years ago Alan added a new mode (c-toggle-cpp-indent-to-body) which
worked around this issue.

At that moment I requested the possibility to make #pragma a syntactic
symbol to control its indentation consistently like anything else in
c-mode (C-c C-o and +, ++, -, 0 or [0]). But such approach required too
many changes in c-mode, so he offered this "toggle" solution.

Now with three-sitter, is it possible to add some way to produce the
desired behavior? Either with a mode as it is in c-mode; or (probably
better) by adding some syntactic entry like: (node-is pragma) in the new
ts-mode indentation function?

I prefer the second one because it seems more consistent with the rest
of the syntax, and not an exception. But I am fine with any solution.

Best, and thanks in advance,
Ergus





This bug report was last modified 2 years and 119 days ago.

Previous Next


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