[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Missing features in c-ts-mode
From: |
Theodor Thornhill |
Subject: |
Re: Missing features in c-ts-mode |
Date: |
Fri, 17 Feb 2023 19:10:28 +0100 |
On 17 February 2023 19:02:28 CET, Ergus <spacibba@aol.com> wrote:
>On Fri, Feb 17, 2023 at 06:34:34PM +0100, Theodor Thornhill wrote:
>>
>>
>> On 17 February 2023 17:37:47 CET, Ergus <spacibba@aol.com> wrote:
>>> Hi Eli and Theo:
>>>
>>> Yes, I know that the feature is not very "popular" to be enabled by
>>> default, but for parallel programming models based on pragmas (OpenMP,
>>> OmpSs, OpenACC) it is very important.
>>>
>>> Many people in my previous work moved to some other editor after years
>>> using emacs due to these apparently "small" details. Every time they
>>> wanted to indent a portion of code (i.e they added an if around it), all
>>> the pragmas moved out of their place and needed manual fix.
>>>
>>> On that moment I commented with Alan the possibility to make #pragma a
>>> syntactc symbol which we could control its indentation like anything
>>> else in c-mode (with +, ++, -, 0 or [0]). But he said that it required
>>> too many changes to implement that and offered this "toggle" solution
>>> good enough for me.
>>>
>>> I will open the feature request in a moment, but just wanted to comment
>>> the alternative solution more consistent and without an extra mode;
>>> because maybe that way may be simpler now in the new mode??
>>>
>>> Best,
>>> Ergus
>>>
>>> On Fri, Feb 17, 2023 at 02:20:59PM +0200, Eli Zaretskii wrote:
>>>>> From: Theodor Thornhill <theo@thornhill.no>
>>>>> Cc: Eli Zaretskii <eliz@gnu.org>, casouri@gmail.com, emacs-devel@gnu.org
>>>>> Date: Fri, 17 Feb 2023 10:56:28 +0100
>>>>>
>>>>> > #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
>>>>> >
>>>>>
>>>>> It's absolutely possible, but IMO that sounds like an improvement for
>>>>> emacs 30, maybe?
>>>>
>>>> It depends on how simple and safe the change will be. But yes, I'm
>>>> okay with delaying this to Emacs 30 if the addition is complex enough.
>>>>
>>>> Thanks.
>>>>
>>
>> Would this mean you'd want all preproc directives configurable, or only
>> some in particular? I think a defcustom for either/or is doable for
>> Emacs 29, but for granular control we'd need to think a bit more.
>>
>> c-ts-mode-preproc-indent-to-body?
>
>
>Hi Theo:
>
>AFAIK only #pragmas have this behavior, so I think a custom for #pragmas
>may be enough if the alternative becomes complex or complicated.
>
>I commented the initial problem as it was just in case tree-sitter
>already have all the spices to go for the general solution in a
>"simpler" way, with a consistent syntax and without an extra
>defcustom/toggle-mode.
>
>Maybe there is a point in between like treat #pragmas as a different
>kind of directive than preproc (which they actually are BTW, #pragmas
>are not exactly preprocesor directives, but hints for the compiler
>itself).
>
>In that case the user could write something more or less like:
> ((node-is "pragma") parent 1)
> ((node-is "pragma") no-indent)
>
>in the indent-style.
>
>WDYT?
>
Yep! Is there any particular style? Would pragmas be indented from the parent
scope, and the next line after it be at the same level as the pragma?
Theo
- Re: Missing features in c-ts-mode, (continued)
- Re: Missing features in c-ts-mode, Ergus, 2023/02/17
- Re: Missing features in c-ts-mode, Eli Zaretskii, 2023/02/17
- Re: Missing features in c-ts-mode, Theodor Thornhill, 2023/02/17
- Re: Missing features in c-ts-mode, Eli Zaretskii, 2023/02/17
- Re: Missing features in c-ts-mode, Ergus, 2023/02/17
- Re: Missing features in c-ts-mode, Theodor Thornhill, 2023/02/17
- Re: Missing features in c-ts-mode, Ergus, 2023/02/17
- Re: Missing features in c-ts-mode,
Theodor Thornhill <=
- Re: Missing features in c-ts-mode, Ergus, 2023/02/17
- Re: Missing features in c-ts-mode, Theodor Thornhill, 2023/02/17
- Re: Missing features in c-ts-mode, Felix, 2023/02/15
- Re: Missing features in c-ts-mode, Eli Zaretskii, 2023/02/16
- Re: Missing features in c-ts-mode, Theodor Thornhill, 2023/02/16
- Re: Missing features in c-ts-mode, Felix, 2023/02/16
- Re: Missing features in c-ts-mode, Eli Zaretskii, 2023/02/15
- Re: Missing features in c-ts-mode, Theodor Thornhill, 2023/02/15
- Re: Missing features in c-ts-mode, Eli Zaretskii, 2023/02/16