Subject: Re: bug#60443: 29.0.60; c-ts-mode: Consider re-using c-file-style and c-basic-offset

From: Yuan Fu <[email-masked]>
Date: Fri, 30 Dec 2022 20:02:55 -0800

> On Dec 30, 2022, at 7:17 PM, Mohammed Sadiq <[email-masked]> wrote:
> 
> It would be nice if c-ts-mode respects c-file-style and c-basic-offset
> instead of its own variables.  Also I wish c-ts-mode respects other c-mode
> variables (ie, cc-styles.el) so that I could use the same c-mode conf for
> c-ts-mode too, eg., I could use:
> 
> /* -*- c-file-style: "gnu"; c-basic-offset: 4; -*- */
> 
> as file variables which would work both in c-mode and c-ts-mode, or the
> following in dir-locals:
> 
> ((nil . ((fill-column . 80)))
>  (c-ts-mode . ((c-file-style . "GNU")
>                (c-file-offsets
>                (brace-list-intro . +)))))
> 
> Whether the mode used for C source file is c-ts-mode or c-mode is an
> implementation detail as far as the settings are concerned (because I
> don't want different styles for my code depending on the mode used).
> 
> I'm not asking about implementing the spacing and indentation rules, but
> when they do, it would be nice if they re-use the same c-mode variable
> names.

IIUC part of the reason why we created separate major modes is that we don’t want to share configuration variables between the tree-sitter and elisp implementation. If they share some of the configuration variable but not all, it would be very confusing; it they share all variables, well that’s not possible because c-ts-mode doesn’t support all of c-mode’s features. Also, since c-ts-mode and c-mode’s implementation differs greatly, some of c-mode’s configuration wouldn’t make sense, or is hard to recreate, in c-ts-mode.

I’m sorry that there will inevitably be differences between c-ts-mode and c-mode. We’ll try to minimize the annoyance but it won’t be perfect.

Yuan