aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorYuan Fu2022-10-25 13:54:12 -0700
committerYuan Fu2022-10-25 14:07:47 -0700
commit7c5d4348330b206aff1f8e5bc4fd241d6a6dc0b5 (patch)
tree8e945b0380e34d86d3206f44980e5bf80f0b298c /test/src
parent06b5ec4bbde119d14d866fc3713a4ed390d531f2 (diff)
downloademacs-7c5d4348330b206aff1f8e5bc4fd241d6a6dc0b5.tar.gz
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')
-rw-r--r--test/src/treesit-tests.el20
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.)"
448 ;; `treesit-search-forward-goto' 448 ;; `treesit-search-forward-goto'
449 )) 449 ))
450 450
451(ert-deftest treesit-misc ()
452 "Misc helper functions."
453 (let ((settings '((t 0 t)
454 (c-mode 1 t)
455 (text-mode 2 nil)
456 (prog-mode 3 t)
457 (fundamental-mode 4 t))))
458 ;; `treesit--setting-for-mode'.
459 ;; Exact match.
460 (should (eq 1 (treesit--setting-for-mode 'c-mode settings)))
461 ;; Inherit from t.
462 (should (eq 0 (treesit--setting-for-mode 'non-exist settings)))
463 ;; Inherit from prog-mode rather than fundamental-mode.
464 (require 'elisp-mode)
465 (should (eq 3 (treesit--setting-for-mode 'emacs-lisp-mode settings)))
466 ;; Not inherit from text-mode.
467 (require 'outline)
468 (should (not (eq 2 (treesit--setting-for-mode 'outline-mode settings))))
469 ))
470
451;; TODO 471;; TODO
452;; - Functions in treesit.el 472;; - Functions in treesit.el
453;; - treesit-load-name-override-list 473;; - treesit-load-name-override-list