Add indentation style setting for c-ts-mode in .dir-locals.el

* lisp/progmodes/c-ts-mode.el (c-ts-indent-style-safep): New
predicate.
(c-ts-mode-indent-style): Use it to test the value for being safe.

* .dir-locals.el (c-ts-mode): Set 'c-ts-mode-indent-style' to 'gnu'.
This commit is contained in:
Eli Zaretskii 2023-04-22 09:41:50 +03:00
parent e7db6c59cc
commit 44145bf07e
2 changed files with 7 additions and 1 deletions

View file

@ -21,7 +21,8 @@
(electric-quote-comment . nil)
(electric-quote-string . nil)
(mode . bug-reference-prog)))
(c-ts-mode . ((indent-tabs-mode . t)
(c-ts-mode . ((c-ts-mode-indent-style . gnu)
(indent-tabs-mode . t)
(mode . bug-reference-prog)))
(log-edit-mode . ((log-edit-font-lock-gnu-style . t)
(log-edit-setup-add-author . t)

View file

@ -136,6 +136,10 @@ symbol."
(loop (append res (list buffer)) (cdr buffers))
(loop res (cdr buffers))))))))
(defun c-ts-indent-style-safep (style)
"Non-nil if STYLE's value is safe for file-local variables."
(and (symbolp style) (not (functionp style))))
(defcustom c-ts-mode-indent-style 'gnu
"Style used for indentation.
@ -150,6 +154,7 @@ follows the form of `treesit-simple-indent-rules'."
(symbol :tag "BSD" bsd)
(function :tag "A function for user customized style" ignore))
:set #'c-ts-mode--indent-style-setter
:safe 'c-ts-indent-style-safep
:group 'c)
(defun c-ts-mode--get-indent-style (mode)