[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 dda4baa58b7: ; Fix build and startup without tree-sitter
From: |
Eli Zaretskii |
Subject: |
emacs-29 dda4baa58b7: ; Fix build and startup without tree-sitter |
Date: |
Mon, 30 Jan 2023 07:24:39 -0500 (EST) |
branch: emacs-29
commit dda4baa58b7e6a5c70f4c40c80463221b3c479c1
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
; Fix build and startup without tree-sitter
* 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 | 1 +
lisp/progmodes/rust-ts-mode.el | 1 +
lisp/treesit.el | 31 +++++++++++++++++--------------
3 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el
index 2d4a0d41c2a..c13b01aae5c 100644
--- a/lisp/progmodes/c-ts-common.el
+++ b/lisp/progmodes/c-ts-common.el
@@ -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
diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el
index 2812e39c101..e317793d211 100644
--- a/lisp/progmodes/rust-ts-mode.el
+++ b/lisp/progmodes/rust-ts-mode.el
@@ -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'."
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 92833fb007c..98f446a1456 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 dda4baa58b7: ; Fix build and startup without tree-sitter,
Eli Zaretskii <=