]> git.eshelyaron.com Git - emacs.git/commit
Use tree-sitter for font-lock's syntactic function (optionally)
authorYuan Fu <casouri@gmail.com>
Mon, 31 Oct 2022 06:59:56 +0000 (23:59 -0700)
committerYuan Fu <casouri@gmail.com>
Mon, 31 Oct 2022 07:23:31 +0000 (00:23 -0700)
commit18947103fabf8070738b3bd9c5a8d02f90988a3d
treebaeae31e780eef59f6299fa865b15c861c717fd9
parent79ee266f13fa5c657b24dc45d5f573c393a671b6
Use tree-sitter for font-lock's syntactic function (optionally)

Before this change, we rebind font-lock-fontify-region-function and
call font-lock's function in tree-sitter's function, and the order of
fontification is tree-sitter, font-lock syntax, font-lock regexp.

Now we make font-lock's syntax function customizable and replace it
with tree-sitter's function, and the order of fontification is
tree-sitter, font-lock regexp.

* doc/lispref/modes.texi (Parser-based Font Lock): Reflect the change
in manual.
* lisp/font-lock.el (font-lock-fontify-syntactically-function): New
varaible.
(font-lock-default-fontify-region): Call
font-lock-fontify-syntactically-function rather.
(font-lock-fontify-syntactically-region): Rename to
font-lock-default-fontify-syntactically
(font-lock-default-fontify-syntactically): Rename to this.

* lisp/treesit.el (treesit-font-lock-fontify-region): Don't call
font-lock functions.
(treesit-font-lock-enable): Remove this function.  It is not used even
before this change.
(treesit-major-mode-setup): Instead of binding
font-lock-fontify-region-function, now bind to
font-lock-fontify-syntactically-function.  And we can let font-lock do
it's thing.
doc/lispref/modes.texi
lisp/font-lock.el
lisp/treesit.el