From: Eli Zaretskii Date: Sat, 22 Apr 2023 06:41:50 +0000 (+0300) Subject: Add indentation style setting for c-ts-mode in .dir-locals.el X-Git-Tag: emacs-29.0.91~114 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=44145bf07e296efe28a29f03edcb685c84afe69a;p=emacs.git 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'. --- diff --git a/.dir-locals.el b/.dir-locals.el index 6733b5326a6..0bcded4b5d1 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -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) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 166399f922d..6100f00e3ba 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -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)