GNU bug report logs - #71244
Limit matches of treesit-thing-settings in js-ts-mode

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Tue, 28 May 2024 16:32:02 UTC

Severity: normal

Fixed in version 30.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 71244 in the body.
You can then email your comments to 71244 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to casouri <at> gmail.com, bug-gnu-emacs <at> gnu.org:
bug#71244; Package emacs. (Tue, 28 May 2024 16:32:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to casouri <at> gmail.com, bug-gnu-emacs <at> gnu.org. (Tue, 28 May 2024 16:32:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Limit matches of treesit-thing-settings in js-ts-mode
Date: Tue, 28 May 2024 19:24:56 +0300
[Message part 1 (text/plain, inline)]
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):

[js--treesit-sexp-nodes.patch (text/x-diff, inline)]
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)

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71244; Package emacs. (Fri, 31 May 2024 06:36:02 GMT) Full text and rfc822 format available.

Message #8 received at 71244 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: 71244 <at> debbugs.gnu.org
Cc: Yuan Fu <casouri <at> gmail.com>
Subject: Re: bug#71244: Limit matches of treesit-thing-settings in js-ts-mode
Date: Fri, 31 May 2024 09:34:39 +0300
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.




bug marked as fixed in version 30.0.50, send any further explanations to 71244 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Fri, 31 May 2024 06:36:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71244; Package emacs. (Thu, 06 Jun 2024 05:23:01 GMT) Full text and rfc822 format available.

Message #13 received at 71244 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 71244 <at> debbugs.gnu.org
Subject: Re: bug#71244: Limit matches of treesit-thing-settings in js-ts-mode
Date: Wed, 5 Jun 2024 22:20:41 -0700

> On May 30, 2024, at 11:34 PM, Juri Linkov <juri <at> 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



bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 04 Jul 2024 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 44 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.