From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vincenzo Pupillo Newsgroups: gmane.emacs.bugs Subject: bug#68879: [PATCH] Compatibility issue with a newer version of tree-sitter-javascript Date: Thu, 1 Feb 2024 16:18:38 +0000 Message-ID: <7625339.EvYhyI6sBW@3-191.divsi.unimi.it> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3546764.iIbC2pHGDl"; micalg="pgp-sha256"; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13143"; mail-complaints-to="usenet@ciao.gmane.io" To: 68879@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 01 21:45:25 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rVdw4-0003AV-HP for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Feb 2024 21:45:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVdvk-0001AV-DY; Thu, 01 Feb 2024 15:45:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVdvh-00019C-Mo for bug-gnu-emacs@gnu.org; Thu, 01 Feb 2024 15:45:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rVdvX-0006sW-Se for bug-gnu-emacs@gnu.org; Thu, 01 Feb 2024 15:45:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rVdvh-0002XT-RL for bug-gnu-emacs@gnu.org; Thu, 01 Feb 2024 15:45:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Vincenzo Pupillo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Feb 2024 20:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68879 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: "bug-gnu-emacs@gnu.org" Original-Received: via spool by submit@debbugs.gnu.org id=B.17068202689697 (code B ref -1); Thu, 01 Feb 2024 20:45:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 Feb 2024 20:44:28 +0000 Original-Received: from localhost ([127.0.0.1]:43202 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rVdv7-0002WI-3w for submit@debbugs.gnu.org; Thu, 01 Feb 2024 15:44:28 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:37396) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rVZrA-0000aB-3R for submit@debbugs.gnu.org; Thu, 01 Feb 2024 11:24:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVZqt-00080w-3D for bug-gnu-emacs@gnu.org; Thu, 01 Feb 2024 11:23:47 -0500 Original-Received: from mail-ve1eur01on0715.outbound.protection.outlook.com ([2a01:111:f400:fe1f::715] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVZqq-0004ZI-Rl for bug-gnu-emacs@gnu.org; Thu, 01 Feb 2024 11:23:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dv3PvHvcTZc5M5u6jyPdv4QRxY6fmU9OHB4pnn37NDUwWHXtYHS0DcEXpeTUy5L2VMIUMyiEMi25oAGDQCVl+L7+AvGIYbBs7Hzw9Ks+7Z7s2cFXl114JiSkvAsgvIgffWE8qCHiPdjWJ3eHk9YgbF1GTvfU+eKHmd+JnS67cnpIugfCCLEyPXRJe++axcFuweToEy+B4MslcvbmaM2qwEh+q2rRIO7SToLVy6UeHfh0w8PDm3BEd6iYvR6ysR9aUiviW6ppbLfCm5kvP3sxOJ33ShsJ6690P/XMUMmoJbsd82XEGuXng+0APSnhFCe9/kr1FXhppSW0Xu3WWW9bMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3XtL8Ti3pKnHxd1WjOyI/eEmZeOJSqt8AaMEUBLhLKQ=; b=JttDXhd0eXJ8t/iriEuNs+WwWFLzCaj5itaNi0dFH0YXm+9mw41SKrWr+l7GajtbmntG91tLGCdPe6CO6IhKxTa9lMa3CaCoyPtCHuP2dZX59cXHaSycl5HnnlwtLWF/seQDWa6cdtwSlsCud5smKPr/bLGO6RJoIcl6ExM/KUGudoDZKZea7IcWbQOkWlZK96i3spOxFQSJRb6bi2ObJ2vnvLArdiJALe8ElgGN9ZJQ0+IZvXcuyhtm1lPU2RIM85DMjagaFsN9PVOfwpTq0zzCaDRmA9gndjQXvMOxuvzrgg+z69U/VaygtlBwwSRBBidnrPnVS+SMU9BhQ8nWAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=unimi.it; dmarc=pass action=none header.from=unimi.it; dkim=pass header.d=unimi.it; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unimi.it; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3XtL8Ti3pKnHxd1WjOyI/eEmZeOJSqt8AaMEUBLhLKQ=; b=MGrWSZHcR239G+PEVY4YUBrho+GbNSrZcsTBztSSGwKAfgrLzgNDUZuUtCl91QYfuRfpJ/F48jMc+0NRSgwAsS5F/JdMqz1qn9F1fn3j5rPr7eo9N87nAO0iWhV+VjQkELsExpZeljHSHt0Z69YejWlhMp1hr2cFqAn7pmjlGh1C15LQ4F6KDJdNJ0ocFnr7VVR4RK2enPJeWgRezwXc77Sq7VQmShs76T9xR2Ug9GYBMcsWj4vHLt0336Yjj97D77mmitb2iXRUvzm0BWytO4ez3sduKz4k5sr2kie3H3owuWBpOloPjvbVYDDywr6pPJ+ydZO2Q7XwD9QLrHluAg== Original-Received: from GV1PR08MB7873.eurprd08.prod.outlook.com (2603:10a6:150:5c::22) by AS2PR08MB9595.eurprd08.prod.outlook.com (2603:10a6:20b:609::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.26; Thu, 1 Feb 2024 16:18:39 +0000 Original-Received: from GV1PR08MB7873.eurprd08.prod.outlook.com ([fe80::8e0:ebf0:f053:b9c8]) by GV1PR08MB7873.eurprd08.prod.outlook.com ([fe80::8e0:ebf0:f053:b9c8%6]) with mapi id 15.20.7249.023; Thu, 1 Feb 2024 16:18:38 +0000 Thread-Topic: [PATCH] Compatibility issue with a newer version of tree-sitter-javascript Thread-Index: AQHaVSpQaPRKodjbL0OhyiQDMuVm0w== Accept-Language: it-IT, en-US Content-Language: en-US X-MS-Has-Attach: yes authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=unimi.it; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: GV1PR08MB7873:EE_|AS2PR08MB9595:EE_ x-ms-office365-filtering-correlation-id: 4547c985-aff8-4e2f-4144-08dc234172f2 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: N1FXrpQ+H7z0idDrBMtkOAMIAqTGljayX0pkt9ubTsde+cMLbm/XsgltZ00LUFQoBWrAgkXhZclFfb9RYZg7BXFxCEzXtZN1tsEgjMP7IOv3wmOdgT3zNVYmjz6+wkhQwnH5ynv+qVtkD6wmtcJ7T1VwfZ5O5kkNE76mgXSEC/54Sh9j0102UkoniG/GTwGYs03JPEigWpb1hTckIKffr5/YG5SVokGsi3cytyss1MKC4TG0COG6m2Kek7To32EdblaSuUlOV16MC8BKz9MuK9+DfiXBXLrAaNQom/q3uXqK1IDd6rqQgchh2OGHeAodvByezwL9oO5Buz9ksLWG3WhOOeU4seFFT7E5nnZxX0V87BI9R2OFJafhjc7ykE90l1Ta6MF+OLawnoB4zv1r4ASS1/3FGDlTv7c3PXSPCO6OCXqc2l23RiHeKlBiD/U4GCo7ujTmQAtQ0hVGTzFNy1PdRt+kJd7elhbXN43pAXFMx2jgNgFbTU26nAz8PAAoBiunpNEIrta9Ak5d/ZP06wfV8OfniYnMZ4dYR7IFC3X2K2Q6fDCcv75qqQZhSvfTa1dW8XFy4KqZeVu/YkG8+0iinWaynbBpj85tdk+43rfVL6G8+pjG3GSEUgVz1DobE5LRhLaO54R7gfUANWEryg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:GV1PR08MB7873.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(376002)(366004)(346002)(396003)(39860400002)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(6486002)(6512007)(478600001)(38070700009)(86362001)(41300700001)(99936003)(26005)(2906002)(6506007)(4744005)(66556008)(6916009)(5660300002)(66476007)(786003)(316002)(66446008)(64756008)(71200400001)(44832011)(8936002)(38100700002)(8676002)(76116006)(66946007)(122000001)(39026012); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: ShDIcD6p/nZAAApj+RSgxtiYhB73nFEz+Ih97pnYRExwBpXRNANS1H9nHQ3bAdpoOzUZlh0Nf3NO3/1oTjpIR86OgYWgJ2FYKydjVHgaxT8WE7je+PDfgqxQdiCQM1beBBcHWry4p+waiKgYKyd280smJRkZsSTmM5j9VwhnZZ9o6gKHqZacrEZjWDU5i1H8Dz2rGSfejC9To6w2gSTdmjsAJ74N76ElXrf/N6/mJl6qXSzF3DzHBRI8nZr6luocwSIGyCyLFEh8CDqz6sTl5+LjGMuOmItOBHSeFc0jsA7WThSrqDGuKBYFGPnko+XfgeV0y48gSQNOiM4pXINeqZE8Su+gjGcGA0Vdj3/LeQ+5s9pvWITI7JNjUfjk44B7334ArVvW2xQuyQw1fdQ3gCy8Soz/3Z/Qg/neJR1HU08ftavylsuIlu+IImd8Q9JUqo04yLwrSzr88dYmRxWleTYHUcyB0VhLPO724EJMyMcwscY/S8262wrjQGeR8fEY26Y4xiVfTM2mnmVjIHfgO3W/wz8wAJ7BJ9sNNXmse+2OotAgCl45rUhE6fd7pwmuxs2cTVEUK1ROfvKIR0x0fWjMsRVqqgTJZKJXKp2Vthmfu4rMlH2WES7KIcHHy7K6zNTenSUUMkdHiH21JG/L3DJGO1huO4Qfwq0USAhjAnySKw1Fz7VVYofE5MsLKVQtPQkbIR4Pnt8tBBUlv8bwY5QhVvSu/HfOpv5QMo6+Cz0dLoJK9C0IjAm8yE LeblHD1J8jJTl869i1wqvhUV9YWGA8PdpCpHPabxW49cHFoJIyhC53Scf8BSisANTEtXmAaZhce4su8XRQ0Qg0Bn7IUCIAN5G4 X-OriginatorOrg: unimi.it X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: GV1PR08MB7873.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4547c985-aff8-4e2f-4144-08dc234172f2 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Feb 2024 16:18:38.7567 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 13b55eef-7018-4674-a3d7-cc0db06d545c X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 7BW7vfL3LMwJ5nIWzRg2VvH0aA8Uz3RXIn7BFfbTyCZmEe0F3ffEepz1KUkSg5ipiia/C5HsVJ5iE3jX4ua3Z0246Cx3Yv47dlwQ8Jab4mI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9595 Received-SPF: pass client-ip=2a01:111:f400:fe1f::715; envelope-from=vincenzo.pupillo@unimi.it; helo=EUR01-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 01 Feb 2024 15:44:23 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:279305 Archived-At: --nextPart3546764.iIbC2pHGDl Content-Type: multipart/mixed; boundary="nextPart3790165.kQq0lBPeGt"; protected-headers="v1" Content-Transfer-Encoding: base64 From: Vincenzo Pupillo To: bug-gnu-emacs@gnu.org Date: Thu, 01 Feb 2024 17:18:31 +0100 Message-ID: <7625339.EvYhyI6sBW@3-191.divsi.unimi.it> Organization: =?UTF-8?B?VW5pdmVyc2l0w6A=?= degli Studi di Milano MIME-Version: 1.0 This is a multi-part message in MIME format. --nextPart3790165.kQq0lBPeGt Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Hi,=20 starting from version 0.20.2 (released yesterday) of tree-sitter-javascript= =20 the "function" primary expression has been renamed to "function_expression"= =2E=20 The attached patch (for emacs 29) supports the old and new versions. I also have a version for emacs 30. Thank you.=20 V. =2D-=20 Vincenzo Pupillo Direzione ICT Universit=E0 degli Studi di Milano / University of Milan (Italy) Via Giuseppe Colombo, 46, 20133 Milano --nextPart3790165.kQq0lBPeGt Content-Disposition: attachment; filename="0001-Fixed-incompatibility-with-tree-sitter-javascrip-0.2.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="x-UTF_8J"; name="0001-Fixed-incompatibility-with-tree-sitter-javascrip-0.2.patch" >From 91b8853fb71e72f65b135535cf4d2bb3f1d3722f Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo 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 --nextPart3790165.kQq0lBPeGt-- --nextPart3546764.iIbC2pHGDl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: base64 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRRXpCQUFCQ0FBZEZpRUVxekdZNHFxb1ZY eDFSTzBIZmkrai9mOS8rR0FGQW1XN3hGY0FDZ2tRZmkrai9mOS8KK0dBVXpRZ0FnZXBpQWVxdnlD ZmZiSklrbStXWmZqam04eGZrT0M3bEJuTTFDa1Zqb2J6T1NJNzIwSEN0MEQ0SApQd0RjcURaVGxM YmM0UXI2WUtiQ3B0ZjRZT2tBVlFJdklSSFdIL3p3eS83dldXWDJmUmoyMTF6dmtRQkJyczV3Ckhu VHZOcUQwbmNLTU40ZG1JYllkMDZIeTlZbStkSW0vaXBSek8ybEpvTU1YTU82bEJ6NW5RM1BXWGla dXRReE8KZkdtN1VYWE1PWXVSWmFsb1F6UEZxc0FoQm1NWHB2NFJDbmFJNWpGM2hVOVhJYm5HcERs b3FKM3J5c2pMZzUvRApwdlM5Y0loemJNR1FCa1QvUWhMUkxxYnhpZVRDQWJ0c2ppNGVyOVpZckpi S1NoQmlVM3BvM00wOURmcTgvNVhaClc2SGRpR2t6VGsveXVLS0FLNkxYZVplV01RcHcrQT09Cj1G TmY1Ci0tLS0tRU5EIFBHUCBTSUdOQVRVUkUtLS0tLQo= --nextPart3546764.iIbC2pHGDl--