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: Wed, 25 Dec 2024 09:52:33 +0200 Organization: LINKOV.NET Message-ID: <87cyhg2nyu.fsf@mail.linkov.net> References: <87plox4mtp.fsf@masteringemacs.org> <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> <8abcb53c-1636-450d-ac0c-fdf44566ab95@gutov.dev> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33111"; 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: Yuan Fu , 74963@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 25 09:12:21 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 1tQMVB-0008UR-Ej for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 25 Dec 2024 09:12:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQMUw-0000BJ-1H; Wed, 25 Dec 2024 03:12:06 -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 1tQMUu-0000Ah-9g for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2024 03:12:04 -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 1tQMUu-0003MG-0N for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2024 03:12:04 -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=FUJWD0Z3+VeltHrOm43vJ2phUJQcofJR4crGuGXkVk0=; b=PNrN8DRg41iUaLCTIwcmgg5P4QcnLRHrx95vxPPBb/hkxcyVmVPsRvdrKNY9FnRybDTyxM2mQJ/cT3FR8XNvhVWvlhlzWWsWIrYSl3VqnUDcX4Eg4LF5knHxK/C2JHwwACNEnj9fMykYN6WbbYshdJDQAYs6JBebxkhepTYwamsFCuHKYk3wlrv+LNtUntnUy35lbc51Kd0KMeo1NopyTc0nGGIn3xJ2Q2/MtL2G34NyMoD9+LTg8dvENXbWkTdJO4saLbpPkAPCoLzCJRCgcPTumkRbZ99OIQaFWyHQqY8yWuMvgN1OJRb5VhrexRL2MoXSrXw3CiUHRLT1rdh6ag==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tQMUt-0005tA-Rx for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2024 03:12:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Dec 2024 08:12:03 +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.173511428222553 (code B ref 74963); Wed, 25 Dec 2024 08:12:03 +0000 Original-Received: (at 74963) by debbugs.gnu.org; 25 Dec 2024 08:11:22 +0000 Original-Received: from localhost ([127.0.0.1]:36057 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tQMUE-0005rg-G3 for submit@debbugs.gnu.org; Wed, 25 Dec 2024 03:11:22 -0500 Original-Received: from relay8-d.mail.gandi.net ([217.70.183.201]:51827) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tQMU9-0005r4-68 for 74963@debbugs.gnu.org; Wed, 25 Dec 2024 03:11:17 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id E56D71BF204; Wed, 25 Dec 2024 08:10:48 +0000 (UTC) In-Reply-To: <8abcb53c-1636-450d-ac0c-fdf44566ab95@gutov.dev> (Dmitry Gutov's message of "Wed, 25 Dec 2024 05:25:24 +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:297718 Archived-At: >> 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")'. > > Given that we're already calling a predicate every time (in > ruby-ts-mode), we might as well add one more check. See the patch at the > end. Thanks, I tried the patch. It was broken, so needed to edit manually. Also the new key 'w' doesn't work in diff buffers, need to fix it as well. > Speaking of tricky examples though, here's a definition: > > module Bar > class Foo > def baz > end > end > end > > If you move point inside the keyword "module" or "class", C-M-f wouldn't > move forward either as of the latest master. No such problem with "def". > > Adding the check for "named" fixes the first two cases, but then C-M-f > inside "def" jumps to after "baaz". Could be worked around with a > special case, but I wonder what this difference comes from (haven't > properly debugged yet). I see no problems with your patch. Everything works nicely.