Subject: Re: bug#78814: 31.0.50; problems setting custom c++-ts-mode indent style

From: Eli Zaretskii <[email-masked]>
Date: Sat, 21 Jun 2025 12:18:14 +0300

> From: "Jacek Świerk" <[email-masked]>
> Date: Tue, 17 Jun 2025 07:17:39 +0200
> 
> I encountered two separate issues while configuring a non-default
> indentation style in c++-ts-mode (although one of them also applies to
> c-ts-mode).
> 
> When invoking C-c . to set a style, c-ts-mode-set-style incorrectly sets
> treesit-simple-indent-rules to nil, preventing proper indentation.
> 
> I believe the issue stems from a typo in the c-ts-mode-set-style
> function. Specifically, when the mode is c++-ts-mode, the function
> passes the symbol 'c++ to c-ts-mode--simple-indent-rules, but the
> function expects the symbol 'cpp instead.
> 
> To reproduce:
> 
> M-x c++-ts-mode
> C-c . and pick any style
> C-h v treesit-simple-indent-rules should show nil and indentation does
> not work correctly

Thanks, I fixed this typo on the master branch.

> As for the second issue, in definitions of both c-ts-mode and
> c++-ts-mode, treesit-simple-indent-rules is derived from the return
> value of c-ts-mode--simple-indent-rules (lines 1486 and 1559). However,
> if the user customizes the indentation style by setting
> c-ts-mode-indent-style to a function, the current implementation breaks.
> The c-ts-mode--simple-indent-rules function expects one of the four
> predefined styles, but when c-ts-mode-indent-style is a custom function,
> it does not handle this correctly.
> 
> To reproduce:
> 
> Set c-ts-mode-indent-style to some custom function
> M-x c++-ts-mode
> C-h v treesit-simple-indent-rules should show ((cpp)) and indentation
> does not work correctly

Thanks, but please show a more detailed recipe, with a specific custom
function, so I could more easily investigate this issue.
Alternatively provide more details about what goes wrong in the code
in this case, in particular of this sentence:

> The c-ts-mode--simple-indent-rules function expects one of the four
> predefined styles, but when c-ts-mode-indent-style is a custom function,
> it does not handle this correctly.

I don't understand which call to c-ts-mode--simple-indent-rules is at
fault here, and what does "does not handle this correctly" mean.