emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/tree-sitter 7c750343be: * lisp/treesit.el (treesit-font-lock-ena


From: Yuan Fu
Subject: feature/tree-sitter 7c750343be: * lisp/treesit.el (treesit-font-lock-enable): Add function back.
Date: Fri, 21 Oct 2022 21:52:57 -0400 (EDT)

branch: feature/tree-sitter
commit 7c750343be6309a78d3fd289959bca241d9daf5d
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    * lisp/treesit.el (treesit-font-lock-enable): Add function back.
---
 lisp/treesit.el | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lisp/treesit.el b/lisp/treesit.el
index 136b756bad..3096a21f6f 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -508,6 +508,18 @@ If LOUDLY is non-nil, message some debugging information."
   (let ((font-lock-unfontify-region-function #'ignore))
     (funcall #'font-lock-default-fontify-region start end loudly)))
 
+(defun treesit-font-lock-enable ()
+  "Enable tree-sitter font-locking for the current buffer."
+  (treesit-font-lock-recompute-features)
+  (setq-local font-lock-fontify-region-function
+              #'treesit-font-lock-fontify-region)
+  ;; If we don't set `font-lock-defaults' to some non-nil value,
+  ;; font-lock doesn't enable properly (`font-lock-mode-internal'
+  ;; doesn't run).  See `font-lock-specified-p'.
+  (when (null font-lock-defaults)
+    (setq font-lock-defaults '(nil)))
+  (font-lock-mode 1))
+
 ;;; Indent
 
 (defvar treesit--indent-verbose nil



reply via email to

[Prev in Thread] Current Thread [Next in Thread]