]> git.eshelyaron.com Git - emacs.git/commitdiff
; Fix build and startup without tree-sitter
authorEli Zaretskii <eliz@gnu.org>
Mon, 30 Jan 2023 12:22:19 +0000 (14:22 +0200)
committerEli Zaretskii <eliz@gnu.org>
Mon, 30 Jan 2023 12:22:19 +0000 (14:22 +0200)
* lisp/treesit.el (treesit--font-lock-level-setter): Don't loop
over all the buffers if tree-sitter is not built-in, or else
initialization of defcustom will fail.  (Bug#61155)
* lisp/progmodes/rust-ts-mode.el (treesit-node-parent):
* lisp/progmodes/c-ts-common.el (treesit-node-parent): Declare, to
* avoid byte-compilation warnings.

lisp/progmodes/c-ts-common.el
lisp/progmodes/rust-ts-mode.el
lisp/treesit.el

index 2d4a0d41c2a32adc2831429829adfc0d09c41d46..c13b01aae5cfcb9351f59f514f64e0adc0158a70 100644 (file)
@@ -50,6 +50,7 @@
 (declare-function treesit-node-start "treesit.c")
 (declare-function treesit-node-end "treesit.c")
 (declare-function treesit-node-type "treesit.c")
+(declare-function treesit-node-parent "treesit.c")
 
 ;;; Comment indentation and filling
 
index 2812e39c1010b11a036fe6517a3f76225fdfbeae..e317793d21151ac48860b67d29575a6283d0503d 100644 (file)
@@ -37,6 +37,7 @@
 (declare-function treesit-node-child-by-field-name "treesit.c")
 (declare-function treesit-node-start "treesit.c")
 (declare-function treesit-node-type "treesit.c")
+(declare-function treesit-node-parent "treesit.c")
 
 (defcustom rust-ts-mode-indent-offset 4
   "Number of spaces for each indentation step in `rust-ts-mode'."
index 92833fb007ca5fbc06dee02e62059dc37701ff24..98f446a14565915cf1510d22625b86f9a6d8153b 100644 (file)
@@ -87,6 +87,7 @@
 (declare-function treesit-search-subtree "treesit.c")
 (declare-function treesit-search-forward "treesit.c")
 (declare-function treesit-induce-sparse-tree "treesit.c")
+(declare-function treesit-subtree-stat "treesit.c")
 
 (declare-function treesit-available-p "treesit.c")
 
@@ -557,20 +558,22 @@ omitted, default END to BEG."
 (defun treesit--font-lock-level-setter (sym val)
   "Custom setter for `treesit-font-lock-level'."
   (set-default sym val)
-  (named-let loop ((res nil)
-                   (buffers (buffer-list)))
-    (if (null buffers)
-        (mapc (lambda (b)
-                (with-current-buffer b
-                  (setq-local treesit-font-lock-level val)
-                  (treesit-font-lock-recompute-features)
-                  (treesit-font-lock-fontify-region (point-min) (point-max))))
-              res)
-      (let ((buffer (car buffers)))
-        (with-current-buffer buffer
-          (if (treesit-parser-list)
-              (loop (append res (list buffer)) (cdr buffers))
-            (loop res (cdr buffers))))))))
+  (and (treesit-available-p)
+       (named-let loop ((res nil)
+                        (buffers (buffer-list)))
+         (if (null buffers)
+             (mapc (lambda (b)
+                     (with-current-buffer b
+                       (setq-local treesit-font-lock-level val)
+                       (treesit-font-lock-recompute-features)
+                       (treesit-font-lock-fontify-region (point-min)
+                                                         (point-max))))
+                   res)
+           (let ((buffer (car buffers)))
+             (with-current-buffer buffer
+               (if (treesit-parser-list)
+                   (loop (append res (list buffer)) (cdr buffers))
+                 (loop res (cdr buffers)))))))))
 
 (defcustom treesit-font-lock-level 3
   "Decoration level to be used by tree-sitter fontifications.