]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix 'c-ts-mode' indentation when the style is defined as a function
authorEli Zaretskii <eliz@gnu.org>
Sun, 22 Jun 2025 08:16:53 +0000 (11:16 +0300)
committerEshel Yaron <me@eshelyaron.com>
Tue, 24 Jun 2025 06:29:11 +0000 (08:29 +0200)
* lisp/progmodes/c-ts-mode.el (c-ts-mode, c++-ts-mode): Handle the
case where 'c-ts-mode-indent-style' is a function.  (Bug#78814)

(cherry picked from commit 081c1aae992549bc9ef6f0f85c4d4cf6a8fe84cb)

lisp/progmodes/c-ts-mode.el

index 0df9fe39e3669b4be216e0a63ef853e8423e21ac..5155193c6030a6d6afcff4e3f6d76fd71bb80b83 100644 (file)
@@ -1487,8 +1487,10 @@ in your init files."
       (setq-local comment-end " */")
       ;; Indent.
       (setq-local treesit-simple-indent-rules
-                  (c-ts-mode--simple-indent-rules
-                   'c c-ts-mode-indent-style))
+                  (if (functionp c-ts-mode-indent-style)
+                      (funcall c-ts-mode-indent-style)
+                    (c-ts-mode--simple-indent-rules
+                     'c c-ts-mode-indent-style)))
       ;; (setq-local treesit-simple-indent-rules
       ;;             `((c . ,(alist-get 'gnu (c-ts-mode--indent-styles 'c)))))
       ;; Font-lock.
@@ -1560,8 +1562,10 @@ recommended to enable `electric-pair-mode' with this mode."
 
       ;; Indent.
       (setq-local treesit-simple-indent-rules
-                  (c-ts-mode--simple-indent-rules
-                   'cpp c-ts-mode-indent-style))
+                  (if (functionp c-ts-mode-indent-style)
+                      (funcall c-ts-mode-indent-style)
+                    (c-ts-mode--simple-indent-rules
+                     'cpp c-ts-mode-indent-style)))
 
       ;; Font-lock.
       (setq-local treesit-font-lock-settings