]> git.eshelyaron.com Git - emacs.git/commit
Revise the toggle scheme of tree-sitter (again)
authorYuan Fu <casouri@gmail.com>
Wed, 19 Oct 2022 23:44:04 +0000 (16:44 -0700)
committerYuan Fu <casouri@gmail.com>
Wed, 19 Oct 2022 23:44:04 +0000 (16:44 -0700)
commit5159789e55d64c7482dff3dc1a621d01f530f83c
tree37226a815710fd704c02b8ad08a498cfe4887c34
parent4c328daf0130fc139e827a8a8d6689e2b15c73ea
Revise the toggle scheme of tree-sitter (again)

Now instead of a toggle function (major-mode-backend-function), we let
major mode set local variables like treesit-font-lock-settings,
treesit-imenu-function, then treesit-mode takes care of activating
those things (clearing font-lock-keywords, setting
imenu-create-index-function to treesit-imenu-function, etc).

js.el and python.el: I've returned js-mode and python-mode to exactly
what they were before tree-sitter change, plus lines at the end
setting up tree-sitter variables.  Sorry about all these fuss :-D

* lisp/treesit.el (treesit-mode-inhibit-message): Remove option.
(major-mode-backend-function)
(treesit-remapped-major-mode-alist): Remove variables.
(treesit-mode): Move down to the end of buffer.  Do more things.
(global-treesit-mode): Move down to the end of buffer.  Don't handle
major-mode-remap-alist anymore.
(global-treesit-mode--turn-on): Move down to the end of buffer.
(treesit-ready-p): Move down to the end of buffer.  Changed signature.
(treesit-font-lock-enable): Remove function.
(treesit-defun-type-regexp): New variable.
(treesit-beginning-of-defun)
(treesit-end-of-defun): New function.
(treesit-imenu-function): New variable.
(treesit-mode-supported)
(treesit-required-languages)
(treesit--local-variable-backup): New variables.
(treesit--backup-local-variable): New function

* lisp/progmodes/js.el (js-use-tree-sitter): Remove option.
(js--treesit-defun-type-regexp): Remove variable.  (Now set inline in
js-mode.)
(js--treesit-beginning-of-defun)
(js--treesit-end-of-defun): Remove functions.  (Now use
treesit-beginning/end-of-defun.)
(js--backend-toggle)
(js--json-backend-toggle): Remove function.
(js-mode)
(js-json-mode): Restore back to before tree-sitter changes.  Add
tree-sitter setup at the end.

* lisp/progmodes/python.el (python--backend-toggle): Remove function.
(python-mode): Restore back to before tree-sitter changes.  Add
tree-sitter setup at the end.

* lisp/progmodes/ts-mode.el (ts-mode--font-lock-settings): Use
js--fontify-template-string.
(ts-mode--fontify-template-string): Remove function (because we can
just use js--fontify-template-string).
(ts-mode--defun-type-regexp): Remove variable (now set inline in
ts-mode).
(ts-mode--beginning-of-defun)
(ts-mode--end-of-defun): Remove functions (now using
treesit-beginning/end-of-defun).
(ts-mode): Setup tree-sitter variables and then turn on treesit-mode
or move to js-mode.
lisp/progmodes/js.el
lisp/progmodes/python.el
lisp/progmodes/ts-mode.el
lisp/treesit.el