From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#74612: 30.0.90; [PATCH] Allow passing nil to treesit-node-match-p Date: Thu, 05 Dec 2024 11:43:58 +0200 Message-ID: <868qsuxy5d.fsf@gnu.org> References: <2D3B1979-C9A2-4843-8F64-DC26FA42EE25@gmail.com> <867c8lb2yz.fsf@gnu.org> <6FD7EC70-CA0B-46CE-9829-B33B4D38523B@gmail.com> <86ed2r67vl.fsf@gnu.org> 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="34798"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74612-done@debbugs.gnu.org To: casouri@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 05 10:45:24 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 1tJ8QF-0008r3-ED for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Dec 2024 10:45:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJ8Q0-0001LD-Rm; Thu, 05 Dec 2024 04:45: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 1tJ8Pu-0001Kn-Uo for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 04:45: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 1tJ8Pu-0006bo-C2 for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 04:45: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:References:In-Reply-To:From:Date:To:Subject; bh=0g+et7N8m/DCTVWYUaPKXCLzlE4OhZaOWnH1210mYxQ=; b=TbqMrvktWaZh6/lRU+4CMwU/p/6XXLB0bQUrMGeQ+Lv/Tr3vehBzQkZZ7UrwM239VScXS7pUTJCzLTdj8MhtlOsjjvFDSZJ2H+aPeBYNXeuz/u6POsjZlG/zDzq+pQRkdHxGjrZYfJXb33zHaFIDtS24hScgUigCDt2RYRF99u6l6/HIWFEoss8hVB23il7bL3w84HCVPXyFSST4oXBH0xiXRFiocNrPNQYdY4fzSRbi6u2+Pe/4NqsyMQPgxHRhjVWMZyaV4XQf6n8ye0PBf57IBg0QlHRMGU4Dx/LE0gFslgE5ywBR0xhtSu0qRgFPti4bxwNYn+nNtNJx7C/KcQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tJ8Pu-0002p0-6z for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 04:45:02 -0500 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Dec 2024 09:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 74612 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Mail-Followup-To: 74612@debbugs.gnu.org, eliz@gnu.org, casouri@gmail.com Original-Received: via spool by 74612-done@debbugs.gnu.org id=D74612.173339187910781 (code D ref 74612); Thu, 05 Dec 2024 09:45:01 +0000 Original-Received: (at 74612-done) by debbugs.gnu.org; 5 Dec 2024 09:44:39 +0000 Original-Received: from localhost ([127.0.0.1]:38312 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJ8PX-0002np-6h for submit@debbugs.gnu.org; Thu, 05 Dec 2024 04:44:39 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60410) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJ8PU-0002nZ-Bh for 74612-done@debbugs.gnu.org; Thu, 05 Dec 2024 04:44:37 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tJ8PP-0006Yw-3n; Thu, 05 Dec 2024 04:44:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=0g+et7N8m/DCTVWYUaPKXCLzlE4OhZaOWnH1210mYxQ=; b=mHE3noeK4mvrjVfYKkcS hexoT7jFqtaekc3ah+Lq1OgLQZNUrZa/b6dgLUFB73kHCdpyK9AeAKCj5vLhAPo2pnPSFxjmVuHm9 +LI/Dv0UfHZB6UuA2qvn8cipWIq5oxWPwQ4AVcJeCqyyZBmDznP8NG96fkQ9IDOd2DENVfT4GAm0X NVZatfWFRXt6pCAZuUvQo74szZYMKAVEe3zbWl55RpFzW1kJ7ecJ9ch4czhkIDfkizmOepLLsmxbR J+dou05MZGTYPmSsgWimqegaL2eCugdS/M+eeP7ZGlX2A0WXRaUsz3zzABL3IXw/GlGeOfmwpSG6X c5ndEBql55I4ug==; In-Reply-To: <86ed2r67vl.fsf@gnu.org> (message from Eli Zaretskii on Sun, 01 Dec 2024 11:59:58 +0200) 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:296466 Archived-At: > Cc: 74612@debbugs.gnu.org > Date: Sun, 01 Dec 2024 11:59:58 +0200 > From: Eli Zaretskii > > > From: Yuan Fu > > Date: Sun, 1 Dec 2024 00:31:05 -0800 > > Cc: 74612@debbugs.gnu.org > > > > > > > > > On Nov 29, 2024, at 11:22 PM, Eli Zaretskii wrote: > > > > > >> From: Yuan Fu > > >> Date: Fri, 29 Nov 2024 16:38:22 -0800 > > >> > > >> Eli, are you ok with this patch on emacs-30? Almost all tree-sitter node functions allows user to pass nil for NODE, so treesit-node-match-p should too. > > > > > > Does this solve an actual problem you've seen somewhere (and if so, > > > which problem), or does it solve a potential problem that didn't > > > actually happen yet? > > > > I encountered this problem (more like an inconvenience, since without this feature I’d need to test for nullness before passing a node to treesit-node-match-p) when using treesit-node-match-p for some new code I’m writing for master branch. Since (treesit-node-match-p node “type name”) is easier to write and shorter than (equal (treesit-node-type node) “type name”) or (string-match-p “type name regex” (treesit-node-type node)), I’ve been using it liberally in new code :) > > > > > > > > Also, does CHECK_TS_NODE allow nil or does it currently signal an > > > error? > > > > CHECK_TS_NODE currently signals an error. All the tree-sitter node functions that accepts nil has the "if (NILP (node)) return Qnil” line before CHECK_TS_NODE (or treesit_check_node) > > > > If you’re not too comfortable with the change, we can apply it to master. It wouldn’t create any backward-incompatibility since this change makes treesit-node-match-p more lenient on its argument, not stricter. The drawback is treesit-node-match-p will be a bit more annoying to use. > > OK, please install on emacs-30, and thanks. I see you did, so I'm closing this bug.