From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode Date: Tue, 24 Dec 2024 09:41:58 +0200 Organization: LINKOV.NET Message-ID: <87ldw5o7cp.fsf@mail.linkov.net> References: <87plox4mtp.fsf@masteringemacs.org> <86ikueiekp.fsf@mail.linkov.net> <86ed4zg1cc.fsf@mail.linkov.net> <87zflac68t.fsf@mail.linkov.net> <87jzcdlxdp.fsf@mail.linkov.net> <87o71jocgs.fsf@mail.linkov.net> <5192B278-66C0-48AE-B881-E57CCBB6B501@gmail.com> <87frmtbc9z.fsf@mail.linkov.net> <86bjxh1h86.fsf@gnu.org> <87y10l8h6k.fsf@mail.linkov.net> <87ldwl8g60.fsf@mail.linkov.net> <87wmg53rdj.fsf@mail.linkov.net> <87a5d0n651.fsf@mail.linkov.net> <87zfktphks.fsf@mail.linkov.net> <87ttb0rwni.fsf_-_@mail.linkov.net> <4DFCFBC8-A353-48F2-8257-D6CFB155A030@gmail.com> <87ttatpnii.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29472"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: Dmitry Gutov , 74963@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 24 08:44:29 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 1tPzaf-0007Xo-Ag for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 24 Dec 2024 08:44:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tPzaK-0001aR-TW; Tue, 24 Dec 2024 02:44:08 -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 1tPzaF-0001aD-J7 for bug-gnu-emacs@gnu.org; Tue, 24 Dec 2024 02:44:03 -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 1tPzaE-0003Yk-80 for bug-gnu-emacs@gnu.org; Tue, 24 Dec 2024 02:44:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=jcKzwD2q82xRiJk7ffUmNVF8QtGQ6effSQhFEaOVnTQ=; b=quQuKXjl3ZizUj9wpnEXJJhHP9bMm6HEM+z9jW/d0nmKe3NB6ub5p1n8UHqFp70FzUTEHC/q2i/eziWVhh20EDsBmByKmrkK02FqKcJfc1UwknTj07zJcHOmvKqfNUdGF/ijWvLXEn2u67z+8yXBciWGw5vi0dLkbc79knmT/fQZsFC8vzSXeKqArwqy1tcj+6SyoA1wn+Aci1pIe3w57+r4b1AVACiUA76VF65BL0kMwuo+AbGodm8H02a/XnwqIiWPoSgfAq+KeSSSabpJDyhqJIPB7wpRyZ3A0fRw3UsTb3zDDysghewAl2OxEGrAkjzQTRDXwTbyn1oNqP1kQw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tPzaD-0008B7-I3 for bug-gnu-emacs@gnu.org; Tue, 24 Dec 2024 02:44:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 24 Dec 2024 07:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74963 X-GNU-PR-Package: emacs Original-Received: via spool by 74963-submit@debbugs.gnu.org id=B74963.173502622331380 (code B ref 74963); Tue, 24 Dec 2024 07:44:01 +0000 Original-Received: (at 74963) by debbugs.gnu.org; 24 Dec 2024 07:43:43 +0000 Original-Received: from localhost ([127.0.0.1]:59195 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tPzZv-0008A4-42 for submit@debbugs.gnu.org; Tue, 24 Dec 2024 02:43:43 -0500 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:40395) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tPzZs-00089d-K1 for 74963@debbugs.gnu.org; Tue, 24 Dec 2024 02:43:41 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 41414240005; Tue, 24 Dec 2024 07:43:29 +0000 (UTC) In-Reply-To: <87ttatpnii.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 24 Dec 2024 09:17:33 +0200") X-GND-Sasl: juri@linkov.net 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:297686 Archived-At: > (setq-local treesit-thing-settings > `((ruby > (sexp ,(cons (rx > bol > (or > "class" > ... > ) > eol) > #'ruby-ts--sexp-p)) BTW, I just fixed a bug in typescript-ts-mode where "string_fragment" was mismatched by "string", because its regexp-opt matched node names too widely, so needed to enclose in regexp anchors. I see that all ts-modes solve this common problem each in its own way (here 'list' indicates a list of strings that should match node names): c-ts-mode: (regexp-opt list 'symbols) js-ts-mode: (concat "\\_<" (regexp-opt list t) "\\_>") java-ts-mode: (rx (or list)) ruby-ts-mode: (rx bol (or list) eol) Currently there is no uniform way to handle this frequent need. 'concat' like above looks too ugly, but 'regexp-opt' with the 'symbols' arg produces a strange regexp for matching symbols. Maybe better would be create a new argument for 'regexp-opt', e.g.: (regexp-opt list 'complete) that will expand to: (concat "^" list "$")