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

समीर सिंह Sameer Singh <[email protected]> Mon, 18 May 2026 06:07:33 -0500
Newsgroups gmane.emacs.help
Message-ID <CAOR1sLxRNmB4by2rXiOwmR7bYpPWcdXmK6ZcUva2xrHjB0kYkA@mail.gmail.com>
I have a .dir-locals.el file with the following content:

;;; Directory Local Variables            -*- no-byte-compile: t -*-
;;; For more information see (info "(emacs) Directory Variables")

((c-ts-mode . ((c-ts-mode-indent-style . bsd))))

but the c files in the project does not follow the specified style for
whatever reason. If I "describe-var" `c-ts-mode-indent-style' it says:

c-ts-mode-indent-style is a variable defined in ‘c-ts-mode.el’.

Its value is ‘bsd’
Original value was ‘gnu’
Local in buffer test.c; global value is gnu

Style used for indentation.

The selected style could be one of GNU, K&R, LINUX or BSD.  If the
supplied styles don’t suffice, the value could be a function instead.
This function takes no arguments and is expected to return a list of
indent RULEs as described in ‘treesit-simple-indent-rules’.  Note that
the list of RULEs doesn’t need to contain the language symbol.

  This variable’s value is directory-local, set by the file
  ‘/home/ss141309/code/project-dir/.dir-locals.el’.
  This variable is safe as a file local variable if its value
  satisfies the predicate ‘c-ts-indent-style-safep’.
  This variable was introduced, or its default value was changed, in
  version 29.1 of Emacs.
  You can customize this variable.
  Setting this variable directly with ‘setq’ may not take effect;
  use either customize or ‘setopt’, or call ‘c-ts-mode--indent-style-setter’.

If I set the style using "C-c . bsd RET" then the file correctly follows
the "bsd" style.

This problem does not seem to be present in c-mode, if I set my vars as:

;;; Directory Local Variables            -*- no-byte-compile: t -*-
;;; For more information see (info "(emacs) Directory Variables")

((c-ts-mode . ((c-ts-mode-indent-style .  bsd)))
 (c-mode    . ((c-file-style           . "BSD"))))

Then c-mode successfully follows the indentation style.

What am I doing wrong?

-- 
समीरसिंह