[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guar
From: |
Theodor Thornhill |
Subject: |
bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif |
Date: |
Sat, 18 Feb 2023 22:30:06 +0100 |
Theodor Thornhill <theo@thornhill.no> writes:
> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Theodor Thornhill <theo@thornhill.no>
>>> Cc: 61558@debbugs.gnu.org
>>> Date: Fri, 17 Feb 2023 20:49:23 +0100
>>>
>>> Can you test this patch? It seems to work for me, but I'm no C expert.
>>
>> Thanks, this is much better. However, the handling of #if (as opposed
>> to #ifdef) is still incorrect. For example, go to the end of line
>> 3376 of dispnew.c and type RET: point goes to column zero, not column
>> 2. If you convert "#if" to #ifdef", the behavior becomes correct.
>> Same problem exists with #elif.
>>
>> Doesn't tree-sitter grammar consider #if and #elif preprocessor nodes?
>
> It seems we are at the mercy of this[0] issue here, in all the cases
> you've described.
>
>>
>> Also, there's a problem with #define in the middle of code. For
>> example, here:
>>
>> /* Put a `display' property on the string for the captions to display,
>> put a `menu_item' property on tab-bar items with a value that
>> is the index of the item in F's tab-bar item vector. */
>> for (i = 0; i < f->n_tab_bar_items; ++i)
>> {
>> #define PROP(IDX) \
>> AREF (f->tab_bar_items, i * TAB_BAR_ITEM_NSLOTS + (IDX))
>>
>> caption = Fcopy_sequence (PROP (TAB_BAR_ITEM_CAPTION)); <<<<<<<<<<
>>
>> /* Put a `display' text property on the string for the caption to
>> display. Put a `menu-item' property on the string that gives
>> the start of this item's properties in the tab-bar items
>> vector. */
>> AUTO_LIST2 (props, Qmenu_item, make_fixnum (i * TAB_BAR_ITEM_NSLOTS));
>>
>> Fadd_text_properties (make_fixnum (0), make_fixnum (SCHARS (caption)),
>> props, caption);
>>
>> f->desired_tab_bar_string =
>> concat2 (f->desired_tab_bar_string, caption);
>>
>> #undef PROP <<<<<<<<<<<<<<<<<<<<
>> }
>>
>> Typing RET at the end of the two marked lines goes to column zero
>> instead of the expected non-zero column. So it sounds like #define
>> and #undef are also not handled correctly yet.
>
> Yeah, luckily it indents correctly after you start to type. I'll try to
> see if I can make some specific handling for this.
>
> Theo
>
Scratch that. Can you test this for me? I think I got it.
Theo
0001-Cleanup-preproc-indent-for-c-ts-mode.patch
Description: Text Data
>
> [0]: https://github.com/tree-sitter/tree-sitter-c/issues/97
- bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif, Eli Zaretskii, 2023/02/16
- bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif, Theodor Thornhill, 2023/02/17
- bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif, Eli Zaretskii, 2023/02/17
- bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif, Theodor Thornhill, 2023/02/17
- bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif, Eli Zaretskii, 2023/02/18
- bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif, Theodor Thornhill, 2023/02/18
- bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif,
Theodor Thornhill <=
- bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif, Eli Zaretskii, 2023/02/19
- bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif, Theodor Thornhill, 2023/02/19
- bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif, Eli Zaretskii, 2023/02/19
- bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif, Theodor Thornhill, 2023/02/19
bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif, Yuan Fu, 2023/02/24