From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Basil Contovounesios via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#64019: 29.0.91; Fix some tree-sitter :match regexps Date: Tue, 13 Jun 2023 15:08:01 +0100 Message-ID: <87fs6vbgla.fsf@epfl.ch> References: <87o7lkzrj1.fsf@epfl.ch> <1959ea93-0ca3-59cd-3abb-e841bd337c57@gutov.dev> Reply-To: Basil Contovounesios Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17215"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Randy Taylor , Yuan Fu , 64019@debbugs.gnu.org, Theodor Thornhill , Daniel Colascione To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 13 16:09:24 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 1q94i4-0004GB-Js for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Jun 2023 16:09:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q94hl-0000S6-H6; Tue, 13 Jun 2023 10:09:05 -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 1q94hj-0000Rm-3x for bug-gnu-emacs@gnu.org; Tue, 13 Jun 2023 10:09:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q94hi-0001Wi-Re for bug-gnu-emacs@gnu.org; Tue, 13 Jun 2023 10:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q94hi-0000JY-A4 for bug-gnu-emacs@gnu.org; Tue, 13 Jun 2023 10:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Basil Contovounesios Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 13 Jun 2023 14:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64019 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 64019-submit@debbugs.gnu.org id=B64019.16866652921144 (code B ref 64019); Tue, 13 Jun 2023 14:09:02 +0000 Original-Received: (at 64019) by debbugs.gnu.org; 13 Jun 2023 14:08:12 +0000 Original-Received: from localhost ([127.0.0.1]:42614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q94gt-0000IN-N5 for submit@debbugs.gnu.org; Tue, 13 Jun 2023 10:08:12 -0400 Original-Received: from mail-wm1-f49.google.com ([209.85.128.49]:44159) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q94gr-0000I8-JU for 64019@debbugs.gnu.org; Tue, 13 Jun 2023 10:08:11 -0400 Original-Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-3f8cc04c278so5306485e9.0 for <64019@debbugs.gnu.org>; Tue, 13 Jun 2023 07:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; t=1686665283; x=1689257283; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=bgwOJUxhCGEx1aoI4uQxxL3bUZaVipsfL1iHOMeh1p4=; b=T5oczAtC7RLdaig0oZB5CwTY26wKASYtO/OT69VlR+jn7cfQTHbLNwl+8iT8r6OI9t wfniGxmVsjz+S7B1I1LbLKNCNEIHfrgeLT+Ku7UKPxxaz7vPUe+Q+P8v/t+JPmYeoXMJ v+PxVK/GVimAOMZiVI3y/VmEh9yB0BP8FD1jyUGbqLdj6A+/pEnz1ILCkrWx0wfY/1bB y20gKKB3OrZ0rcdKJJ9C/YmhLWcaSJk7wF94WjPXT+9EuAcQkw6o0UpJYS+1FwdlzaqI MXkYRyGwhT751f0pVI3t3c11bkgXFDHF5LmAe5CdvwFgfMz3/R800ea2RgXeQsr16vRz /kFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686665283; x=1689257283; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bgwOJUxhCGEx1aoI4uQxxL3bUZaVipsfL1iHOMeh1p4=; b=buDu7Yx30jER1Sctyocjh2L2EU4jB4pcCpwlqzLPgwErh99mXPVGX6GJ+i7DNaKoBW UzaHZUVB3LK/6VIE4LNp3ddpTG2HgKc0d0KDatc8ZEoXRvK1jTwqu2XuG/VEO3edZWbe YzmkOdywyBjnHA3qBNDrSdvWvMLO/Ag2aE2Feb1EbYSfT66XlXLd6/XNUgP436lTnCSX Mkb7gDI5AGxIwlZtNPT9vj2gwTPxXNVOJnUHz7ZAP49WMmEwxxipC+2v2v25zC9TbUnM CoXwb1lIefvhePp1j7Bnpt9Sy9DlgTxae+Z3v7iPnMnyJmsaAJW2+U7eSwB7810iKge9 3PlQ== X-Gm-Message-State: AC+VfDwGViS2VZO6IWEmvwiiW+6nCJRPtRdRmCiWnTMSY+cP4MKob3Je ij0UJyEcj0lo0j7gXmPcPbw++g== X-Google-Smtp-Source: ACHHUZ6di3ZaLM+eazRA15CjHcxkIhMyrYnX/zYNSrG1Fjx9aAFws0eKppORj+aZ0QcV34LmugpikQ== X-Received: by 2002:a05:600c:21d0:b0:3f6:f152:1183 with SMTP id x16-20020a05600c21d000b003f6f1521183mr8863597wmj.37.1686665283576; Tue, 13 Jun 2023 07:08:03 -0700 (PDT) Original-Received: from localhost ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id u9-20020a05600c00c900b003f72468833esm14612857wmm.26.2023.06.13.07.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 07:08:02 -0700 (PDT) In-Reply-To: <1959ea93-0ca3-59cd-3abb-e841bd337c57@gutov.dev> (Dmitry Gutov's message of "Tue, 13 Jun 2023 00:33:08 +0300") 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:263322 Archived-At: --=-=-= Content-Type: text/plain Dmitry Gutov [2023-06-13 00:33 +0300] wrote: > On 12/06/2023 17:25, Basil L. Contovounesios via Bug reports for GNU Emacs, the > Swiss army knife of text editors wrote: >> - (:match "^DEFUN$" @fn)) >> + (:match "\\`DEFUN\\'" @fn)) > > FWIW, most of these changes are superfluous, practically speaking I'm less concerned about the trivial bol/bos conversions in the patch and more about the corrections to incorrect regexps, such as: - the more benign \(:?...\) -> \(?:...\) - and the less benign [\d] -> [0-9]. > because node text for these node types (like 'identifier', in this > example) cannot include newlines. > > So we mostly gain some theoretical increase in strictness, We also gain the fact that the next one looking at these regexps doesn't need to figure out whether newlines can appear in this context: the regexp immediately says it's intended to match the whole given text rather than a line of text. > at the expense of a few extra chars in the code. That's not really an expense, but a symptom of our regexp syntax, so it can't be helped. > So I think we could wait until 29.1's release, for example, and then apply this > on master. Those parts that will end up applied on master don't need to wait for 29.1, do they? If so, why? Here's the updated patch against emacs-29: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-some-tree-sitter-match-regexps.patch >From fd04e8b781634a0c193435d3d3f175dc9a60975f Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Tue, 13 Jun 2023 13:53:31 +0100 Subject: [PATCH] Fix some tree-sitter :match regexps The shy groups were caught by modified versions of the GNU ELPA packages xr and relint: - https://github.com/mattiase/xr/pull/6 - https://github.com/mattiase/relint/pull/14 * lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings): * lisp/progmodes/js.el (js--plain-method-re): (js--treesit-font-lock-settings): * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--font-lock-settings): * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--font-lock-settings): Replace character alternative [\\d], which matches '\' or 'd', with the most likely intention [0-9]. Fix shy groups mistyped as optional colons. Remove unneeded numbered :match group in rust-ts-mode (bug#64019). --- lisp/progmodes/java-ts-mode.el | 2 +- lisp/progmodes/js.el | 6 +++--- lisp/progmodes/rust-ts-mode.el | 13 ++++++++----- lisp/progmodes/typescript-ts-mode.el | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 463872dcbc8..7f2fc4188a3 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -168,7 +168,7 @@ java-ts-mode--font-lock-settings :override t :feature 'constant `(((identifier) @font-lock-constant-face - (:match "\\`[A-Z_][A-Z_\\d]*\\'" @font-lock-constant-face)) + (:match "\\`[A-Z_][0-9A-Z_]*\\'" @font-lock-constant-face)) [(true) (false)] @font-lock-constant-face) :language 'java :override t diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 414b6eb2baf..48fecf69537 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -106,7 +106,7 @@ js--opt-cpp-start (defconst js--plain-method-re (concat "^\\s-*?\\(" js--dotted-name-re "\\)\\.prototype" - "\\.\\(" js--name-re "\\)\\s-*?=\\s-*?\\(\\(:?async[ \t\n]+\\)function\\)\\_>") + "\\.\\(" js--name-re "\\)\\s-*?=\\s-*?\\(\\(?:async[ \t\n]+\\)function\\)\\_>") "Regexp matching an explicit JavaScript prototype \"method\" declaration. Group 1 is a (possibly-dotted) class name, group 2 is a method name, and group 3 is the `function' keyword.") @@ -3493,7 +3493,7 @@ js--treesit-font-lock-settings :language 'javascript :feature 'constant '(((identifier) @font-lock-constant-face - (:match "\\`[A-Z_][A-Z_\\d]*\\'" @font-lock-constant-face)) + (:match "\\`[A-Z_][0-9A-Z_]*\\'" @font-lock-constant-face)) [(true) (false) (null)] @font-lock-constant-face) @@ -3612,7 +3612,7 @@ js--treesit-font-lock-settings :feature 'number '((number) @font-lock-number-face ((identifier) @font-lock-number-face - (:match "\\`\\(:?NaN\\|Infinity\\)\\'" @font-lock-number-face))) + (:match "\\`\\(?:NaN\\|Infinity\\)\\'" @font-lock-number-face))) :language 'javascript :feature 'operator diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el index b55af0b49e3..999c1d7ae96 100644 --- a/lisp/progmodes/rust-ts-mode.el +++ b/lisp/progmodes/rust-ts-mode.el @@ -143,7 +143,7 @@ rust-ts-mode--font-lock-settings eol)) @font-lock-builtin-face))) ((identifier) @font-lock-type-face - (:match "\\`\\(:?Err\\|Ok\\|None\\|Some\\)\\'" @font-lock-type-face))) + (:match "\\`\\(?:Err\\|Ok\\|None\\|Some\\)\\'" @font-lock-type-face))) :language 'rust :feature 'comment @@ -232,9 +232,12 @@ rust-ts-mode--font-lock-settings (type_identifier) @font-lock-type-face ((scoped_identifier name: (identifier) @rust-ts-mode--fontify-tail)) ((scoped_identifier path: (identifier) @font-lock-type-face) - (:match - "\\`\\(u8\\|u16\\|u32\\|u64\\|u128\\|usize\\|i8\\|i16\\|i32\\|i64\\|i128\\|isize\\|char\\|str\\)\\'" - @font-lock-type-face)) + (:match ,(rx bos + (or "u8" "u16" "u32" "u64" "u128" "usize" + "i8" "i16" "i32" "i64" "i128" "isize" + "char" "str") + eos) + @font-lock-type-face)) ((scoped_identifier path: (identifier) @rust-ts-mode--fontify-scope)) ((scoped_type_identifier path: (identifier) @rust-ts-mode--fontify-scope)) (type_identifier) @font-lock-type-face) @@ -249,7 +252,7 @@ rust-ts-mode--font-lock-settings :feature 'constant `((boolean_literal) @font-lock-constant-face ((identifier) @font-lock-constant-face - (:match "\\`[A-Z][A-Z\\d_]*\\'" @font-lock-constant-face))) + (:match "\\`[A-Z][0-9A-Z_]*\\'" @font-lock-constant-face))) :language 'rust :feature 'variable diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 5df34de0472..68aefd90f92 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -153,7 +153,7 @@ typescript-ts-mode--font-lock-settings :language language :feature 'constant `(((identifier) @font-lock-constant-face - (:match "\\`[A-Z_][A-Z_\\d]*\\'" @font-lock-constant-face)) + (:match "\\`[A-Z_][0-9A-Z_]*\\'" @font-lock-constant-face)) [(true) (false) (null)] @font-lock-constant-face) :language language @@ -311,7 +311,7 @@ typescript-ts-mode--font-lock-settings :feature 'number `((number) @font-lock-number-face ((identifier) @font-lock-number-face - (:match "\\`\\(:?NaN\\|Infinity\\)\\'" @font-lock-number-face))) + (:match "\\`\\(?:NaN\\|Infinity\\)\\'" @font-lock-number-face))) :language language :feature 'operator -- 2.34.1 --=-=-= Content-Type: text/plain WDYT? Thanks, -- Basil --=-=-=--