summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2022-09-07 13:20:37 -0700
committerYuan Fu <casouri@gmail.com>2022-09-07 13:20:37 -0700
commita23aec59b3a6ed2e96a89dab18f51a6310f1ac7c (patch)
treede4457cee70a2984e236141791b84eff748229ca /lisp
parent31ad906bd00a3c624ce024f7caa62e9f0b381b37 (diff)
downloademacs-a23aec59b3a6ed2e96a89dab18f51a6310f1ac7c.tar.gz
emacs-a23aec59b3a6ed2e96a89dab18f51a6310f1ac7c.tar.bz2
emacs-a23aec59b3a6ed2e96a89dab18f51a6310f1ac7c.zip
Remove treesit-disabled-modes and change treesit-should-enable-p
Per emacs-devel discussion, remove treesit-disabled-modes and let major modes to provide tree-sitter switches. I also decided to add treesit-max-buffer-size to elisp manual despite it being a user option. Though we should still add it to the user manual. * doc/lispref/parsing.texi (Parsing Program Source): Update manual to remove entries for treesit-diabled-modes and add treesit-max-buffer-size. Also update treesit-should-enable-p. * lisp/treesit.el (treesit-disabled-modes): Remove user option. (treesit-maximum-size): Change to treesit-max-buffer-size. (treesit-should-enable-p): Change to treesit-can-enable-p and remove checks of treesit-disabled-modes.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/treesit.el27
1 files changed, 7 insertions, 20 deletions
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 9c66f32ec27..83d80ac6dab 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -35,11 +35,7 @@
"Tree-sitter is an incremental parser."
:group 'tools)
-(defcustom treesit-disabled-modes nil
- "A list of major-modes for which tree-sitter support is disabled."
- :type '(list symbol))
-
-(defcustom treesit-maximum-size (* 4 1024 1024)
+(defcustom treesit-max-buffer-size (* 4 1024 1024)
"Maximum buffer size for enabling tree-sitter parsing."
:type 'integer)
@@ -47,21 +43,12 @@
"Return non-nil if tree-sitter features are available."
(fboundp 'treesit-parser-create))
-(defun treesit-should-enable-p (&optional mode)
- "Return non-nil if MODE should activate tree-sitter support.
-MODE defaults to the value of `major-mode'. The result depends
-on the value of `treesit-disabled-modes',
-`treesit-maximum-size', and of course, whether tree-sitter is
-available on the system at all."
- (let* ((mode (or mode major-mode))
- (disabled (cl-loop
- for disabled-mode in treesit-disabled-modes
- if (provided-mode-derived-p mode disabled-mode)
- return t
- finally return nil)))
- (and (treesit-available-p)
- (not disabled)
- (< (buffer-size) treesit-maximum-size))))
+(defun treesit-can-enable-p ()
+ "Return non-nil if current buffer can activate tree-sitter.
+Currently this function checks whether tree-sitter is available
+and the buffer size."
+ (and (treesit-available-p)
+ (< (buffer-size) treesit-maximum-size)))
;;; Parser API supplement