* bug#71244: Limit matches of treesit-thing-settings in js-ts-mode
@ 2024-05-28 16:24 Juri Linkov
2024-05-31 6:34 ` Juri Linkov
0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2024-05-28 16:24 UTC (permalink / raw)
To: 71244; +Cc: Yuan Fu
[-- Attachment #1: Type: text/plain, Size: 347 bytes --]
Navigation in js-ts-mode is still quite unusable
when "expression" in 'js--treesit-sexp-nodes'
matches "expression_statement". Whereas it should match
only "expression" and "parenthesized_expression".
So here is the patch that adds delimiters "\\_<" and "\\_>"
around node names by 'js--regexp-opt-symbol' (and adds
some useful nodes as well):
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: js--treesit-sexp-nodes.patch --]
[-- Type: text/x-diff, Size: 1424 bytes --]
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 6cb84592896..f5629ff8fbe 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3829,6 +3829,8 @@ js--treesit-sentence-nodes
(defvar js--treesit-sexp-nodes
'("expression"
+ "parenthesized_expression"
+ "formal_parameters"
"pattern"
"array"
"function"
@@ -3846,7 +3848,12 @@ js--treesit-sexp-nodes
"undefined"
"arguments"
"pair"
- "jsx")
+ "jsx"
+ "statement_block"
+ "object"
+ "object_pattern"
+ "named_imports"
+ "class_body")
"Nodes that designate sexps in JavaScript.
See `treesit-thing-settings' for more information.")
@@ -3889,10 +3896,10 @@ js-ts-mode
(setq-local treesit-thing-settings
`((javascript
- (sexp ,(regexp-opt js--treesit-sexp-nodes))
- (sentence ,(regexp-opt js--treesit-sentence-nodes))
- (text ,(regexp-opt '("comment"
- "template_string"))))))
+ (sexp ,(js--regexp-opt-symbol js--treesit-sexp-nodes))
+ (sentence ,(js--regexp-opt-symbol js--treesit-sentence-nodes))
+ (text ,(js--regexp-opt-symbol '("comment"
+ "template_string"))))))
;; Fontification.
(setq-local treesit-font-lock-settings js--treesit-font-lock-settings)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#71244: Limit matches of treesit-thing-settings in js-ts-mode
2024-05-28 16:24 bug#71244: Limit matches of treesit-thing-settings in js-ts-mode Juri Linkov
@ 2024-05-31 6:34 ` Juri Linkov
2024-06-06 5:20 ` Yuan Fu
0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2024-05-31 6:34 UTC (permalink / raw)
To: 71244; +Cc: Yuan Fu
close 71244 30.0.50
thanks
> Navigation in js-ts-mode is still quite unusable
> when "expression" in 'js--treesit-sexp-nodes'
> matches "expression_statement". Whereas it should match
> only "expression" and "parenthesized_expression".
>
> So here is the patch that adds delimiters "\\_<" and "\\_>"
> around node names by 'js--regexp-opt-symbol' (and adds
> some useful nodes as well):
With no objections, this is pushed now.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#71244: Limit matches of treesit-thing-settings in js-ts-mode
2024-05-31 6:34 ` Juri Linkov
@ 2024-06-06 5:20 ` Yuan Fu
0 siblings, 0 replies; 3+ messages in thread
From: Yuan Fu @ 2024-06-06 5:20 UTC (permalink / raw)
To: Juri Linkov; +Cc: 71244
> On May 30, 2024, at 11:34 PM, Juri Linkov <juri@linkov.net> wrote:
>
> close 71244 30.0.50
> thanks
>
>> Navigation in js-ts-mode is still quite unusable
>> when "expression" in 'js--treesit-sexp-nodes'
>> matches "expression_statement". Whereas it should match
>> only "expression" and "parenthesized_expression".
>>
>> So here is the patch that adds delimiters "\\_<" and "\\_>"
>> around node names by 'js--regexp-opt-symbol' (and adds
>> some useful nodes as well):
>
> With no objections, this is pushed now.
Thanks Juri!
Yuan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-06 5:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-28 16:24 bug#71244: Limit matches of treesit-thing-settings in js-ts-mode Juri Linkov
2024-05-31 6:34 ` Juri Linkov
2024-06-06 5:20 ` Yuan Fu
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).