diff options
author | Yuan Fu <casouri@gmail.com> | 2022-10-25 13:54:12 -0700 |
---|---|---|
committer | Yuan Fu <casouri@gmail.com> | 2022-10-25 14:07:47 -0700 |
commit | 7c5d4348330b206aff1f8e5bc4fd241d6a6dc0b5 (patch) | |
tree | 8e945b0380e34d86d3206f44980e5bf80f0b298c /test/src/treesit-tests.el | |
parent | 06b5ec4bbde119d14d866fc3713a4ed390d531f2 (diff) | |
download | emacs-7c5d4348330b206aff1f8e5bc4fd241d6a6dc0b5.tar.gz emacs-7c5d4348330b206aff1f8e5bc4fd241d6a6dc0b5.tar.bz2 emacs-7c5d4348330b206aff1f8e5bc4fd241d6a6dc0b5.zip |
New tree-sitter toggle scheme
This version: central variable, everything controlled by
treesit-settings. Major mode sets up tree-sitter/non-tree-sitter
in a conditional branch, based on the setting.
* lisp/treesit.el (treesit-settings): New option.
(treesit-defun-type-regexp): Change docstring.
(treesit-mode-supported)
(treesit-required-languages)
(treesit--local-variable-backup): Remove variables.
(treesit--backup-local-variable)
(treesit-mode)
(global-treesit-mode--turn-on)
(global-treesit-mode): Remove functions.
(treesit--setting-for-mode): New function.
(treesit-ready-p): New argument MODE, changed REPORT to QUIET, and
LANGUAGEs to LANGUAGE (now it can be a single symbol or a list of
them).
(treesit-major-mode-setup): New function. Mostly comes from
treesit-mode.
* test/src/treesit-tests.el (treesit-misc): New test.
* lisp/progmodes/python.el (python-mode): Move some setup code into
the conditional branch at the end.
* lisp/progmodes/js.el (js-json-mode)
(js-mode): Move some setup code into the conditional branch at the
end.
* lisp/progmodes/ts-mode.el: Move tree-sitter setup into the
conditional branch.
Diffstat (limited to 'test/src/treesit-tests.el')
-rw-r--r-- | test/src/treesit-tests.el | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el index adc17bc079a..2e26df69258 100644 --- a/test/src/treesit-tests.el +++ b/test/src/treesit-tests.el @@ -448,6 +448,26 @@ visible_end.)" ;; `treesit-search-forward-goto' )) +(ert-deftest treesit-misc () + "Misc helper functions." + (let ((settings '((t 0 t) + (c-mode 1 t) + (text-mode 2 nil) + (prog-mode 3 t) + (fundamental-mode 4 t)))) + ;; `treesit--setting-for-mode'. + ;; Exact match. + (should (eq 1 (treesit--setting-for-mode 'c-mode settings))) + ;; Inherit from t. + (should (eq 0 (treesit--setting-for-mode 'non-exist settings))) + ;; Inherit from prog-mode rather than fundamental-mode. + (require 'elisp-mode) + (should (eq 3 (treesit--setting-for-mode 'emacs-lisp-mode settings))) + ;; Not inherit from text-mode. + (require 'outline) + (should (not (eq 2 (treesit--setting-for-mode 'outline-mode settings)))) + )) + ;; TODO ;; - Functions in treesit.el ;; - treesit-load-name-override-list |