[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Average-user-facing interface for tree-sitter
From: |
Theodor Thornhill |
Subject: |
Re: Average-user-facing interface for tree-sitter |
Date: |
Thu, 20 Oct 2022 09:44:01 +0200 |
Yuan Fu <casouri@gmail.com> writes:
>>
>> It seems we've had some regressions _after_
>> 851a8f65e9a6b00b51f6a41f4c8f2ec2a797862b, I presume with the major mode
>> toggles, so font-locking has ceased to work properly. One thing I see
>> is that the "warn" isn't a symbol in the new toggle mechanism, so it
>> errors out. But even after that has been fixed it still doesn't work.
>>
>> Why would we want to init the whole js-mode if we already know that we
>> don't want to use it?
>
> Yes, sorry, I made some further changes to js-mode. Could you have a look and
> see if it makes sense?
>
> Thanks,
> Yuan
I'm not sure I really like the new changes. Now we init everything in
js-mode in addition to everything treesitter related. So now stuff like
```
(setq-local font-lock-defaults
(list js--font-lock-keywords nil nil nil nil
'(font-lock-syntactic-face-function
. js-font-lock-syntactic-face-function)))
(setq-local syntax-propertize-function #'js-syntax-propertize)
(add-hook 'syntax-propertize-extend-region-functions
#'syntax-propertize-multiline 'append 'local)
(add-hook 'syntax-propertize-extend-region-functions
#'js--syntax-propertize-extend-region 'append 'local)
(setq-local prettify-symbols-alist js--prettify-symbols-alist)
(setq-local parse-sexp-ignore-comments t)
```
And many before/after change functions are enabled. I don't see any
reason why they should be, and in many cases this will _absolutely_
be difficult to reason about. That's why I did the 'avoid cc-mode
altogether' approach earlier. I'm interested to know why this is
perceived as better than the 'js-use-treesitter' thing we had earlier.
Why not just check for 'global-treesit-mode' or something and then just
jump over everything else than treesit inits?
Also see suggested diff to get ts-mode to work again, as it couldn't
activate in the current revision. This means that the only reason that
js-mode works is because we set the font-lock-defaults earlier.
Wouldn't that mean it works only by accident?
diff --git a/lisp/progmodes/ts-mode.el b/lisp/progmodes/ts-mode.el
index c23f2bec05..670e103eec 100644
--- a/lisp/progmodes/ts-mode.el
+++ b/lisp/progmodes/ts-mode.el
@@ -276,6 +276,8 @@ ts-mode
"function_declaration"
"lexical_declaration")))
;; Font-lock.
+ (unless font-lock-defaults
+ (setq font-lock-defaults '(nil t)))
(setq-local treesit-font-lock-settings ts-mode--font-lock-settings)
(setq-local treesit-font-lock-feature-list '((minimal) (moderate) (full)))
Thanks,
Theo
- Re: Average-user-facing interface for tree-sitter, (continued)
- Re: Average-user-facing interface for tree-sitter, Yuan Fu, 2022/10/18
- Re: Average-user-facing interface for tree-sitter, Stefan Monnier, 2022/10/18
- Re: Average-user-facing interface for tree-sitter, Yuan Fu, 2022/10/18
- Re: Average-user-facing interface for tree-sitter, Stefan Monnier, 2022/10/18
- Re: Average-user-facing interface for tree-sitter, Yuan Fu, 2022/10/18
- Re: Average-user-facing interface for tree-sitter, Stefan Monnier, 2022/10/18
- RE: [External] : Re: Average-user-facing interface for tree-sitter, Drew Adams, 2022/10/18
- Re: Average-user-facing interface for tree-sitter, Yuan Fu, 2022/10/19
- Re: Average-user-facing interface for tree-sitter, Theodor Thornhill, 2022/10/19
- Re: Average-user-facing interface for tree-sitter, Yuan Fu, 2022/10/19
- Re: Average-user-facing interface for tree-sitter,
Theodor Thornhill <=
- Re: Average-user-facing interface for tree-sitter, Stefan Monnier, 2022/10/20
- Re: Average-user-facing interface for tree-sitter, Theodor Thornhill, 2022/10/20
- Re: Average-user-facing interface for tree-sitter, Theodor Thornhill, 2022/10/20
- Re: Average-user-facing interface for tree-sitter, Yuan Fu, 2022/10/20
- Re: Average-user-facing interface for tree-sitter, Yuan Fu, 2022/10/21
- Re: Average-user-facing interface for tree-sitter, Stefan Monnier, 2022/10/21
- Re: Average-user-facing interface for tree-sitter, Fu Yuan, 2022/10/22
- Re: Average-user-facing interface for tree-sitter, Theodor Thornhill, 2022/10/23
- Re: Average-user-facing interface for tree-sitter, Stefan Monnier, 2022/10/24
- Re: Average-user-facing interface for tree-sitter, Stephen Leake, 2022/10/24