Re: c-ts-mode: How to set indent-style in dir-locals
Jean Louis <[email protected]> Tue, 19 May 2026 00:43:07 +0300
| Newsgroups | gmane.emacs.help |
|---|---|
| Organization | GNU Support |
| Message-ID | <[email protected]> |
(describe-variable 'c-ts-mode-indent-style) c-ts-mode-indent-style is a variable defined in ‘c-ts-mode.el’. Its 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 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’. [back] You can see the key clue right there in the documentation: "Setting this variable directly with ‘setq’ may not take effect; use either customize or ‘setopt’, or call ‘c-ts-mode--indent-style-setter’." (describe-function 'c-ts-mode--indent-style-setter) c-ts-mode--indent-style-setter is a native-comp-function in ‘c-ts-mode.el’. (c-ts-mode--indent-style-setter SYM VAL) Inferred type: (function (t t) null) Custom setter for ‘c-ts-mode-set-style’. Apart from setting the default value of SYM to VAL, also change the value of SYM in ‘c-ts-mode’ and ‘c++-ts-mode’ buffers to VAL. SYM should be ‘c-ts-mode-indent-style’, and VAL should be a style symbol. [back] ;; This may work (what you need to do) (c-ts-mode--indent-style-setter 'c-ts-mode-indent-style 'bsd) ;; Or better: (c-ts-mode-set-style 'bsd) -- Jean Louis