Re: c-ts-mode: How to set indent-style in dir-locals

Stéphane Marks <[email protected]> Mon, 18 May 2026 19:01:45 -0400
Newsgroups gmane.emacs.help
Message-ID <CAN+1HbpGPJs1rie6HNs2a9HKviXYSLsXbU-CaTM+s24Hex6u5A@mail.gmail.com>
On Mon, May 18, 2026 at 6:56 PM Michael Heerdegen via Users list for the
GNU Emacs text editor <[email protected]> wrote:

> Stéphane Marks <[email protected]> writes:
>
> > It might be worth trying and adapting something like this in your
> > .dir-locals.el or .dir-locals-2.el file:
> >
> > (
> >  (c-mode . ((eval . (setopt-local c-ts-mode-indent-style 'bsd))))
> >  )
> >
> > 'setopt-local' is new in Emacs 31.
>
> I don't know if this will behave as expected (I guess not), since the
> custom setter loops over all buffers (`c-ts-mode--indent-style-setter').
>
> But it looks like all you have to do for a single buffer is calling
> `c-ts-mode-set-style'?  That's what that setter does.
>

IMO, that setter, and others like it, should be changed to respect buffer
local.  See the Emacs 31 change made to treesit--font-lock-level-setter
commit 86efaec00e01af1e9171c7fa9eb7904af3be0eb3.