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:17:33 +0200 Organization: LINKOV.NET Message-ID: <87ttatpnii.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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21320"; 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:19:15 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 1tPzCF-0005N7-5d for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 24 Dec 2024 08:19:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tPzC4-0004t2-Pb; Tue, 24 Dec 2024 02:19: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 1tPzC2-0004Zf-I6 for bug-gnu-emacs@gnu.org; Tue, 24 Dec 2024 02:19: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 1tPzC2-0000t4-3o for bug-gnu-emacs@gnu.org; Tue, 24 Dec 2024 02:19:02 -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=52LZ6hea06msH2lgg4RCKqa8yCNzmWGQa5RElIAIj+g=; b=afTWGdMUd5p8O7isQp/4BovnjXXcPY8gZn/YVQxREDRsWCVNRGoME7DF40WDOxTc/5ujXjxlLutVrUfsr65AQPpRK15c915jTPgfCSqyOhqB9D8gkHJmt1p4mY2aSg8wrCkuPoSlmYqMu6S79UUEFN1slAuFbnaRD/l1XZXvab2h/7cLkRk4zwxrjSrki4NZe0VJkqzw3s6JA8ZNGYSXr533zRrhEup326nJny18MpLJkdSWciN4I9/cwnYfUEmRtW6HJItyxhm98lOLiVKGN54vmHcozqX46vVCG2LnpbDqbAp9lPgiHZSs/j56/yxokU5CJY8UBUn2iJM2yO7qlQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tPzC1-0006z0-UD for bug-gnu-emacs@gnu.org; Tue, 24 Dec 2024 02:19: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:19: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.173502470026782 (code B ref 74963); Tue, 24 Dec 2024 07:19:01 +0000 Original-Received: (at 74963) by debbugs.gnu.org; 24 Dec 2024 07:18:20 +0000 Original-Received: from localhost ([127.0.0.1]:59155 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tPzBM-0006xt-3n for submit@debbugs.gnu.org; Tue, 24 Dec 2024 02:18:20 -0500 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:37647) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tPzBK-0006xV-DO for 74963@debbugs.gnu.org; Tue, 24 Dec 2024 02:18:19 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 198A41C0004; Tue, 24 Dec 2024 07:17:50 +0000 (UTC) In-Reply-To: <4DFCFBC8-A353-48F2-8257-D6CFB155A030@gmail.com> (Yuan Fu's message of "Mon, 23 Dec 2024 19:02:28 -0800") 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:297685 Archived-At: >>> A better solution IMO is to add some way to distinguish between named and >>> anonymous nodes. I can think of two ways, either add “and” and >>> “named/anonymous” predicate, so (and named “unless”) only matches the named >>> “unless” node; or we add a special syntax such that “(unless)” only matches >>> named nodes, and “\”unless\”” only matches anonymous nodes. >> >> Either predicate or a special syntax is welcome. >> >> This would be more handy than writing a lambda with implicit calls >> of treesit-node-check. > > I’ll go with the (and named “unless”) route because after thinking > about it more, “(unless)” will be hard to work with because the string > predicate is actually a regexp. Thanks. While addition of '(and named "unless")' would be appreciated, I see that currently it's possible to do this by proving a predicate like there is 'ruby-ts--sexp-p' in (setq-local treesit-thing-settings `((ruby (sexp ,(cons (rx bol (or "class" ... ) eol) #'ruby-ts--sexp-p)) Then 'ruby-ts--sexp-p' could check for the named node "unless" as well. But it seems such solution is less efficient than adding '(and named "unless")'.