]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/treesit.el (treesit-font-lock-enable): Add function back.
authorYuan Fu <casouri@gmail.com>
Sat, 22 Oct 2022 01:50:24 +0000 (18:50 -0700)
committerYuan Fu <casouri@gmail.com>
Sat, 22 Oct 2022 01:50:24 +0000 (18:50 -0700)
lisp/treesit.el

index 136b756badde51f70066daa1b076f4738f22b6c0..3096a21f6fec5ed31d4f169b5b7dc51b488f8b04 100644 (file)
@@ -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