From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= Newsgroups: gmane.emacs.bugs Subject: bug#65470: 29.1.50; js-ts-mode: regex pattern can cause incorrect parenthesis matching Date: Tue, 5 Sep 2023 21:31:25 +0200 Message-ID: <2D516F0C-D7A8-49D2-8009-F911EFC55C78@secure.kjonigsen.net> References: <127B5BEA-A24B-48A3-9827-85B7CDB67D10@secure.kjonigsen.net> <5f823f8f-d249-f4a1-71e6-083e47d0d123@gutov.dev> <83jztbeeh2.fsf@gnu.org> <03415a27-f082-b204-cece-19a9859e178d@gutov.dev> <8334zze5l4.fsf@gnu.org> <1363c54f-5109-f000-3333-78d291b2096d@gutov.dev> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_98540599-24EF-4FC2-B6EE-956A88843869" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40841"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu , 65470@debbugs.gnu.org, Theodor Thornhill , btuin@mailo.com, Eli Zaretskii , Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 05 21:32:26 2023 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 1qdbmi-000AJw-6Q for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 05 Sep 2023 21:32:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdbmN-0005B4-Fp; Tue, 05 Sep 2023 15:32:03 -0400 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 1qdbmM-0005Aa-DA for bug-gnu-emacs@gnu.org; Tue, 05 Sep 2023 15:32:02 -0400 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 1qdbmM-0003jM-4w for bug-gnu-emacs@gnu.org; Tue, 05 Sep 2023 15:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qdbmM-0004dl-Gq for bug-gnu-emacs@gnu.org; Tue, 05 Sep 2023 15:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Sep 2023 19:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65470 X-GNU-PR-Package: emacs Original-Received: via spool by 65470-submit@debbugs.gnu.org id=B65470.169394231017819 (code B ref 65470); Tue, 05 Sep 2023 19:32:02 +0000 Original-Received: (at 65470) by debbugs.gnu.org; 5 Sep 2023 19:31:50 +0000 Original-Received: from localhost ([127.0.0.1]:59370 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdbmA-0004dK-0i for submit@debbugs.gnu.org; Tue, 05 Sep 2023 15:31:50 -0400 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:59645) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdbm5-0004d0-Pm for 65470@debbugs.gnu.org; Tue, 05 Sep 2023 15:31:48 -0400 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id E3DAF5C004D; Tue, 5 Sep 2023 15:31:39 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 05 Sep 2023 15:31:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= secure.kjonigsen.net; h=cc:cc:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1693942299; x=1694028699; bh=KtDigxVcT9hHlx+hlHLyJ2T0lrIuXnRc29e Jew2MZCg=; b=LQl5ZGZ9yjsPYLQZUtowkYcryMI+fdAe+e4lucHVhP024puLVqs 5QbFOcbkAud3Yo/e1oofyoX0CijAepCkYrVieWOUQkT4AR1vfC0x3U8VH3MO4MN5 l6WdAZFkPdKbk+lkO1Gws0MW32qnnRBBIGvwae7qHar+o7M7EMyiG3H/E9QnnlT4 fTVelZJHsBgV4jyyoFYA8zYDDWE3VnoK2qEqdzlWKYPKZFK6V7Y2PI1XDqdCEwWj BhB8EJz9J3l7Uh2qz2CzG9YEV9KI3pUSVG3JlBGbGJGpz0L98DqAA+LDyOgc2lH4 KbESyZv+cdgX92fgrFCZhavVvsle0ir+KUw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1693942299; x=1694028699; bh=KtDigxVcT9hHl x+hlHLyJ2T0lrIuXnRc29eJew2MZCg=; b=lYgNvqOs3BIGbcOsMGO1jTYyI8zsZ WwI5dkA8I3HqW5/dmSpa0CffhwyuogO5nwHFxzmk+FKY0kgfzKAC5AGWIZo3+d2j Q7HObRWTLBhQQpCulNcTYDLMh9f2pEn16JoKrGclcaVQpbj0ndKNsPnjtr5rwkPL frGvs+RQ3EHMvt3+CWe7m+u2zH7K0oTrrXv2iOJLSq5HAvfoTMcLMxs7+7Tu4soU yA9fVsy/Qfwdd5hHuoIX48T2rk2rKs7LD0EERtPblFoRqZkPhI7+dPZP88/0k+/n lzxOmjjNInncvHcbC7YKyuyHtCSoEHLsJqsqsN9HZQcB4ozX8uMjaOVdQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehuddgudduhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhkfgtggfuffgjvefvfhfosehmtdhmrehhtdejnecuhfhrohhmpeflohhs thgvihhnucfmjhppnhhighhsvghnuceojhhoshhtvghinhesshgvtghurhgvrdhkjhhonh highhsvghnrdhnvghtqeenucggtffrrghtthgvrhhnpeejtdejffeggfeuffeuvefhveek ffdtiedtffelteeuiefgvdejheeihfehheekgfenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehjohhsthgvihhnsehsvggtuhhrvgdrkhhjohhn ihhgshgvnhdrnhgvth X-ME-Proxy: Feedback-ID: ib2f84088:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 5 Sep 2023 15:31:38 -0400 (EDT) In-Reply-To: <1363c54f-5109-f000-3333-78d291b2096d@gutov.dev> X-Mailer: Apple Mail (2.3731.700.6) 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:269393 Archived-At: --Apple-Mail=_98540599-24EF-4FC2-B6EE-956A88843869 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 1 Sep 2023, at 03:42, Dmitry Gutov wrote: >=20 > On 31/08/2023 15:53, Eli Zaretskii wrote: >>> Date: Thu, 31 Aug 2023 14:15:22 +0300 >>> Cc:jostein@secure.kjonigsen.net,casouri@gmail.com,theo@thornhill.no, >>> jostein@kjonigsen.net,btuin@mailo.com,65470@debbugs.gnu.org >>> From: Dmitry Gutov >>>=20 >>> On 31/08/2023 12:41, Eli Zaretskii wrote: >>>> I'm a bit confused by this discussion. Should I install the patch = on >>>> the emacs-29 branch now, or are you still discussing whether it's >>>> correct? >>> I think we were discussing the typescript modes here. >>>=20 >>> Personally I was waiting for some additional confirmation that my v2 = for >>> js-ts-mode is correct, but I guess we have a silent approval, so we = can >>> install it. >> Good to hear. Then please install it, and thanks. >=20 > All right, installed one for js-ts-mode. Sorry for the somewhat slow response on this. Life has been busy for me = as well :) Based on the infamous =E2=80=9Ccopy, paste & adapt=E2=80=9D methodology = I=E2=80=99ve come up with a patch for typescript-ts-mode and tsx-ts-mode = which seems to work for the simple test case provided above. However the patch for js-ts-mode has lots of =E2=80=A6 interesting stuff = about jsx I have not included, for no other reason than not = understanding what type of use-cases they are meant to support. If someone can provide me some examples for the JSX use-cases, I can try = to make room for TSX-variants of the same code. The patch so far is attached. It=E2=80=99s intentionally -not- optimized = to leave room for TSX cases which may arise, so hopefully no need to = nitpick this yet. --Apple-Mail=_98540599-24EF-4FC2-B6EE-956A88843869 Content-Disposition: attachment; filename=0001-typescript-ts-mode-Fix-syntax-properties-for-regexp-.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-typescript-ts-mode-Fix-syntax-properties-for-regexp-.patch" Content-Transfer-Encoding: quoted-printable =46rom=20db0393034ca8f251dd1d5cedf928f0c0264d61ef=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Jostein=3D20Kj=3DC3=3DB8nigsen?=3D=20= =0ADate:=20Tue,=205=20Sep=202023=2021:29:27=20= +0200=0ASubject:=20[PATCH]=20typescript-ts-mode:=20Fix=20syntax=20= properties=20for=20regexp=0A=20expressions.=0A=0A---=0A=20= lisp/progmodes/typescript-ts-mode.el=20|=2020=20++++++++++++++++++++=0A=20= 1=20file=20changed,=2020=20insertions(+)=0A=0Adiff=20--git=20= a/lisp/progmodes/typescript-ts-mode.el=20= b/lisp/progmodes/typescript-ts-mode.el=0Aindex=20= 441cdc1f7aa..016c62623c7=20100644=0A---=20= a/lisp/progmodes/typescript-ts-mode.el=0A+++=20= b/lisp/progmodes/typescript-ts-mode.el=0A@@=20-473,6=20+473,7=20@@=20= typescript-ts-mode=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(keyword=20string=20escape-sequence)=0A=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(constant=20expression=20identifier=20number=20= pattern=20property)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(function=20bracket=20delimiter)))=0A+=20=20=20=20(setq-local=20= syntax-propertize-function=20#'ts-ts--syntax-propertize)=0A=20=0A=20=20=20= =20=20(treesit-major-mode-setup)))=0A=20=0A@@=20-529,9=20+530,28=20@@=20= tsx-ts-mode=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (keyword=20string=20escape-sequence)=0A=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(constant=20expression=20identifier=20jsx=20number=20= pattern=20property)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(function=20bracket=20delimiter)))=0A+=20=20=20=20(setq-local=20= syntax-propertize-function=20#'ts-ts--syntax-propertize)=0A=20=0A=20=20=20= =20=20(treesit-major-mode-setup)))=0A=20=0A+(defvar=20ts-ts--s-p-query=0A= +=20=20(when=20(treesit-available-p)=0A+=20=20=20=20= (treesit-query-compile=20'typescript=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20'(((regex=20pattern:=20= (regex_pattern)=20@regexp))))))=0A+=0A+(defun=20ts-ts--syntax-propertize=20= (beg=20end)=0A+=20=20(let=20((captures=20(treesit-query-capture=20= 'typescript=20ts-ts--s-p-query=20beg=20end)))=0A+=20=20=20=20= (pcase-dolist=20(`(,name=20.=20,node)=20captures)=0A+=20=20=20=20=20=20= (let*=20((ns=20(treesit-node-start=20node))=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20(ne=20(treesit-node-end=20node))=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20(syntax=20(pcase-exhaustive=20name=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20('regexp=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(cl-decf=20ns)=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (cl-incf=20ne)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(string-to-syntax=20"\"/")))))=0A+=20=20=20=20=20=20=20=20= (put-text-property=20ns=20(1+=20ns)=20'syntax-table=20syntax)=0A+=20=20=20= =20=20=20=20=20(put-text-property=20(1-=20ne)=20ne=20'syntax-table=20= syntax)))))=0A+=0A=20(if=20(treesit-ready-p=20'tsx)=0A=20=20=20=20=20= (add-to-list=20'auto-mode-alist=20'("\\.tsx\\'"=20.=20tsx-ts-mode)))=0A=20= =0A--=20=0A2.39.2=20(Apple=20Git-143)=0A=0A= --Apple-Mail=_98540599-24EF-4FC2-B6EE-956A88843869 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 =E2=80=94 Jostein= --Apple-Mail=_98540599-24EF-4FC2-B6EE-956A88843869--