aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRandy Taylor2023-10-31 22:08:25 -0400
committerEli Zaretskii2023-11-08 14:32:35 +0200
commitfa8cc4c9ee271d88d52f2573d7d1ef54c7d0ca8e (patch)
tree4c5eb143a395db65bb76e9502df2aa3db990b0f0
parent5bdc61bc0efc704c85b78f36f5f7e5f6c42bb877 (diff)
downloademacs-fa8cc4c9ee271d88d52f2573d7d1ef54c7d0ca8e.tar.gz
emacs-fa8cc4c9ee271d88d52f2573d7d1ef54c7d0ca8e.zip
Fix cmake-ts-mode indentation (Bug#66845)
* lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode--indent-rules): Support versions v0.3.0 and v0.4.0 of the grammar. (cmake-ts-mode--font-lock-compatibility-fe9b5e0): Fix docstring.
-rw-r--r--lisp/progmodes/cmake-ts-mode.el14
1 files changed, 11 insertions, 3 deletions
diff --git a/lisp/progmodes/cmake-ts-mode.el b/lisp/progmodes/cmake-ts-mode.el
index 53d471c381a..8fcdcaddc7b 100644
--- a/lisp/progmodes/cmake-ts-mode.el
+++ b/lisp/progmodes/cmake-ts-mode.el
@@ -63,7 +63,15 @@
63 ((parent-is "foreach_loop") parent-bol cmake-ts-mode-indent-offset) 63 ((parent-is "foreach_loop") parent-bol cmake-ts-mode-indent-offset)
64 ((parent-is "function_def") parent-bol cmake-ts-mode-indent-offset) 64 ((parent-is "function_def") parent-bol cmake-ts-mode-indent-offset)
65 ((parent-is "if_condition") parent-bol cmake-ts-mode-indent-offset) 65 ((parent-is "if_condition") parent-bol cmake-ts-mode-indent-offset)
66 ((parent-is "normal_command") parent-bol cmake-ts-mode-indent-offset))) 66 ((parent-is "normal_command") parent-bol cmake-ts-mode-indent-offset)
67 ;;; Release v0.4.0 wraps arguments in an argument_list node.
68 ,@(ignore-errors
69 (treesit-query-capture 'cmake '((argument_list) @capture))
70 `(((parent-is "argument_list") grand-parent cmake-ts-mode-indent-offset)))
71 ;;; Release v0.3.0 wraps the body of commands into a body node.
72 ,@(ignore-errors
73 (treesit-query-capture 'cmake '((body) @capture))
74 `(((parent-is "body") grand-parent cmake-ts-mode-indent-offset)))))
67 "Tree-sitter indent rules for `cmake-ts-mode'.") 75 "Tree-sitter indent rules for `cmake-ts-mode'.")
68 76
69(defvar cmake-ts-mode--constants 77(defvar cmake-ts-mode--constants
@@ -89,8 +97,8 @@
89 "CMake if conditions for tree-sitter font-locking.") 97 "CMake if conditions for tree-sitter font-locking.")
90 98
91(defun cmake-ts-mode--font-lock-compatibility-fe9b5e0 () 99(defun cmake-ts-mode--font-lock-compatibility-fe9b5e0 ()
92 "Indent rules helper, to handle different releases of tree-sitter-cmake. 100 "Font lock helper, to handle different releases of tree-sitter-cmake.
93Check if a node type is available, then return the right indent rules." 101Check if a node type is available, then return the right font lock rules."
94 ;; handle commit fe9b5e0 102 ;; handle commit fe9b5e0
95 (condition-case nil 103 (condition-case nil
96 (progn (treesit-query-capture 'cmake '((argument_list) @capture)) 104 (progn (treesit-query-capture 'cmake '((argument_list) @capture))