From 7d246c359cf3d25cab5134076e393c4d25015827 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Mon, 1 May 2023 19:08:12 +0200
Subject: [PATCH] ; * lisp/progmodes/c-ts-mode.el: allow loading file without
 treesit

---
 lisp/progmodes/c-ts-mode.el | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 4971ed0b7c2..1f420689432 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -1001,13 +1001,14 @@ For BOL see `treesit-simple-indent-rules'."
       (looking-at c-ts-mode--for-each-tail-regexp))))
 
 (defvar c-ts-mode--emacs-c-range-query
-  (treesit-query-compile
-   'emacs-c `(((declaration
-                type: (macro_type_specifier
-                       name: (identifier) @_name)
-                @for-each-tail)
-               (:match ,c-ts-mode--for-each-tail-regexp
-                       @_name))))
+  (and (treesit-available-p)
+       (treesit-query-compile
+        'emacs-c `(((declaration
+                     type: (macro_type_specifier
+                            name: (identifier) @_name)
+                     @for-each-tail)
+                    (:match ,c-ts-mode--for-each-tail-regexp
+                            @_name)))))
   "Query that finds a FOR_EACH_* macro with an unbracketed body.")
 
 (defvar-local c-ts-mode--for-each-tail-ranges nil
-- 
2.39.5