* bug#68879: [PATCH] Compatibility issue with a newer version of tree-sitter-javascript
@ 2024-02-01 16:18 Vincenzo Pupillo
2024-02-02 6:26 ` Eli Zaretskii
2024-02-03 9:21 ` Eli Zaretskii
0 siblings, 2 replies; 5+ messages in thread
From: Vincenzo Pupillo @ 2024-02-01 16:18 UTC (permalink / raw)
To: 68879
[-- Attachment #1.1: Type: text/plain, Size: 435 bytes --]
Hi,
starting from version 0.20.2 (released yesterday) of tree-sitter-javascript
the "function" primary expression has been renamed to "function_expression".
The attached patch (for emacs 29) supports the old and new versions.
I also have a version for emacs 30.
Thank you.
V.
--
Vincenzo Pupillo
Direzione ICT
Università degli Studi di Milano / University of Milan (Italy)
Via Giuseppe Colombo, 46, 20133 Milano
[-- Attachment #1.2: 0001-Fixed-incompatibility-with-tree-sitter-javascrip-0.2.patch --]
[-- Type: text/x-patch, Size: 2806 bytes --]
From 91b8853fb71e72f65b135535cf4d2bb3f1d3722f Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <v.pupillo@gmail.com>
Date: Thu, 1 Feb 2024 16:57:39 +0100
Subject: [PATCH] Fixed incompatibility with tree-sitter-javascrip >= 0.20.2 .
Starting from version 0.20.2 it has the primary expression \"fuction\".
has been renamed to \"function_expression\". A new function checks if
the new primary expression is available, so it returns the correct rules.
*
lisp/progmodes/js.el (js--treesit-font-lock-compatibility-definition-feature):
the new function.
* lisp/progmodes/js.el (js--treesit-font-lock-settings): Use this.
---
lisp/progmodes/js.el | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index e4ccfd73cc7..12c4d0aedb8 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3427,6 +3427,26 @@ c-paragraph-start
;;; Tree sitter integration
+(defun js--treesit-font-lock-compatibility-definition-feature ()
+ "Font lock helper, to handle different releases of tree-sitter-javascript.
+Check if a node type is available, then return the right font lock rules
+for \"definition\" feature."
+ (condition-case nil
+ (progn (treesit-query-capture 'javascript '((function_expression) @cap))
+ ;; starting from 0.20.2
+ '((function_expression
+ name: (identifier) @font-lock-function-name-face)
+ (variable_declarator
+ name: (identifier) @font-lock-function-name-face
+ value: [(function_expression) (arrow_function)])))
+ (error
+ ;; older version
+ '((function
+ name: (identifier) @font-lock-function-name-face)
+ (variable_declarator
+ name: (identifier) @font-lock-function-name-face
+ value: [(function) (arrow_function)])))))
+
(defun js-jsx--treesit-indent-compatibility-bb1f97b ()
"Indent rules helper, to handle different releases of tree-sitter-javascript.
Check if a node type is available, then return the right indent rules."
@@ -3538,8 +3558,7 @@ js--treesit-font-lock-settings
:language 'javascript
:feature 'definition
- '((function
- name: (identifier) @font-lock-function-name-face)
+ `(,@(js--treesit-font-lock-compatibility-definition-feature)
(class_declaration
name: (identifier) @font-lock-type-face)
@@ -3558,10 +3577,6 @@ js--treesit-font-lock-settings
(variable_declarator
name: (identifier) @font-lock-variable-name-face)
- (variable_declarator
- name: (identifier) @font-lock-function-name-face
- value: [(function) (arrow_function)])
-
(variable_declarator
name: [(array_pattern (identifier) @font-lock-variable-name-face)
(object_pattern
--
2.43.0
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#68879: [PATCH] Compatibility issue with a newer version of tree-sitter-javascript
2024-02-01 16:18 bug#68879: [PATCH] Compatibility issue with a newer version of tree-sitter-javascript Vincenzo Pupillo
@ 2024-02-02 6:26 ` Eli Zaretskii
2024-02-02 8:52 ` Vincenzo Pupillo
2024-02-03 9:21 ` Eli Zaretskii
1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2024-02-02 6:26 UTC (permalink / raw)
To: Vincenzo Pupillo; +Cc: 68879
> From: Vincenzo Pupillo <vincenzo.pupillo@unimi.it>
> Date: Thu, 1 Feb 2024 16:18:38 +0000
>
> starting from version 0.20.2 (released yesterday) of tree-sitter-javascript
> the "function" primary expression has been renamed to "function_expression".
>
> The attached patch (for emacs 29) supports the old and new versions.
> I also have a version for emacs 30.
Thanks.
If the version for Emacs 30 is different, i.e. it is not just a matter
of merging the changes you sent with the master branch, please post
the Emacs 30 version as well.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#68879: [PATCH] Compatibility issue with a newer version of tree-sitter-javascript
2024-02-02 6:26 ` Eli Zaretskii
@ 2024-02-02 8:52 ` Vincenzo Pupillo
0 siblings, 0 replies; 5+ messages in thread
From: Vincenzo Pupillo @ 2024-02-02 8:52 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 68879
[-- Attachment #1: Type: text/plain, Size: 903 bytes --]
Hi Eli,
the patch for Emacs 30 is the same.
Thank you
V.
In data venerdì 2 febbraio 2024 07:26:54 CET, Eli Zaretskii ha scritto:
> [Non ricevi spesso messaggi di posta elettronica da eliz@gnu.org. Per informazioni sull'importanza di questo fatto, visita https://aka.ms/LearnAboutSenderIdentification.]
>
> > From: Vincenzo Pupillo <vincenzo.pupillo@unimi.it>
> > Date: Thu, 1 Feb 2024 16:18:38 +0000
> >
> > starting from version 0.20.2 (released yesterday) of tree-sitter-javascript
> > the "function" primary expression has been renamed to "function_expression".
> >
> > The attached patch (for emacs 29) supports the old and new versions.
> > I also have a version for emacs 30.
>
> Thanks.
>
> If the version for Emacs 30 is different, i.e. it is not just a matter
> of merging the changes you sent with the master branch, please post
> the Emacs 30 version as well.
>
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#68879: [PATCH] Compatibility issue with a newer version of tree-sitter-javascript
2024-02-01 16:18 bug#68879: [PATCH] Compatibility issue with a newer version of tree-sitter-javascript Vincenzo Pupillo
2024-02-02 6:26 ` Eli Zaretskii
@ 2024-02-03 9:21 ` Eli Zaretskii
2024-02-03 10:52 ` Vincenzo Pupillo
1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2024-02-03 9:21 UTC (permalink / raw)
To: Vincenzo Pupillo; +Cc: 68879-done
> From: Vincenzo Pupillo <vincenzo.pupillo@unimi.it>
> Date: Thu, 1 Feb 2024 16:18:38 +0000
>
> starting from version 0.20.2 (released yesterday) of tree-sitter-javascript
> the "function" primary expression has been renamed to "function_expression".
>
> The attached patch (for emacs 29) supports the old and new versions.
> I also have a version for emacs 30.
Thanks, installed on the emacs-29 branch, and closing the bug.
Please note the minor changes I made in your commit log message, and
try to follow these conventions in the future.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#68879: [PATCH] Compatibility issue with a newer version of tree-sitter-javascript
2024-02-03 9:21 ` Eli Zaretskii
@ 2024-02-03 10:52 ` Vincenzo Pupillo
0 siblings, 0 replies; 5+ messages in thread
From: Vincenzo Pupillo @ 2024-02-03 10:52 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 68879-done@debbugs.gnu.org
[-- Attachment #1: Type: text/plain, Size: 986 bytes --]
Ok. Thank you.
V.
In data sabato 3 febbraio 2024 10:22:04 CET, Eli Zaretskii ha scritto:
> [Non ricevi spesso messaggi di posta elettronica da eliz@gnu.org. Per
> informazioni sull'importanza di questo fatto, visita
> https://aka.ms/LearnAboutSenderIdentification.]
> > From: Vincenzo Pupillo <vincenzo.pupillo@unimi.it>
> > Date: Thu, 1 Feb 2024 16:18:38 +0000
> >
> > starting from version 0.20.2 (released yesterday) of
> > tree-sitter-javascript
> > the "function" primary expression has been renamed to
> > "function_expression".
> >
> > The attached patch (for emacs 29) supports the old and new versions.
> > I also have a version for emacs 30.
>
> Thanks, installed on the emacs-29 branch, and closing the bug.
>
> Please note the minor changes I made in your commit log message, and
> try to follow these conventions in the future.
--
Vincenzo Pupillo
Direzione ICT
Università degli Studi di Milano / University of Milan (Italy)
Via Giuseppe Colombo, 46, 20133 Milano
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-03 10:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-01 16:18 bug#68879: [PATCH] Compatibility issue with a newer version of tree-sitter-javascript Vincenzo Pupillo
2024-02-02 6:26 ` Eli Zaretskii
2024-02-02 8:52 ` Vincenzo Pupillo
2024-02-03 9:21 ` Eli Zaretskii
2024-02-03 10:52 ` Vincenzo Pupillo
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).