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#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes Date: Sun, 05 Jan 2025 09:37:49 +0200 Organization: LINKOV.NET Message-ID: <87pll190ui.fsf@mail.linkov.net> References: <87plox4mtp.fsf@masteringemacs.org> <87frpm20t7.fsf@masteringemacs.org> <8634lmbs8t.fsf@gnu.org> <87bk0a1u0o.fsf@masteringemacs.org> <86tte2a5o3.fsf@gnu.org> <877cay1lqt.fsf@masteringemacs.org> <86frpma06f.fsf@gnu.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> <87wmfwqg7e.fsf@mail.linkov.net> <8734i5fyv1.fsf@mail.linkov.net> <875xmumpzv.fsf@mail.linkov.net> 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="26678"; 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: Theodor Thornhill , Eli Zaretskii , Mickey Petersen , 73404@debbugs.gnu.org, Stefan Monnier To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 05 08:46:26 2025 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 1tULL6-0006jQ-IC for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Jan 2025 08:46:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tULKy-0008Hf-W1; Sun, 05 Jan 2025 02:46:17 -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 1tULKm-0008Gt-1y for bug-gnu-emacs@gnu.org; Sun, 05 Jan 2025 02:46:13 -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 1tULKk-00087f-Co for bug-gnu-emacs@gnu.org; Sun, 05 Jan 2025 02:46: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=bkg7GX9mtr8zOrFqBQi9cgzEm8ASfIeEJEK1xW7koPg=; b=FjR/MEKiJovdmrX0XSpW5K9qo75F48HlXyLc2GGFzg+yoEqDP+WNeK2WIxDX3NaT/yjSxLeezQryBMl1voXuP+P5jbdbiDEPkKaC48Y1tO1sm6Xh/ZKEVm2URSz2fq6OZ1GiuPlZmerDlYe2QVo1IJhvZbpEpO1+npgl20lDWyYOHULU7Ba6iRd4miHznqpBZ5x9ztvQVawIE99PyuJihyFVqvB2N6jzXmOe86IxTp4sPgG4zjzHkkYISah0lYEwB64xPHxC4OXfaKobuMaUGx+rHfnsykg7bKJpKImD8nM4cpSGte+FqefbxsGsSgDOmR3bGWYErjWUEFUNVk1tVw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tULKk-00020m-7N for bug-gnu-emacs@gnu.org; Sun, 05 Jan 2025 02:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Jan 2025 07:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73404 X-GNU-PR-Package: emacs Original-Received: via spool by 73404-submit@debbugs.gnu.org id=B73404.17360631217644 (code B ref 73404); Sun, 05 Jan 2025 07:46:02 +0000 Original-Received: (at 73404) by debbugs.gnu.org; 5 Jan 2025 07:45:21 +0000 Original-Received: from localhost ([127.0.0.1]:59620 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tULK5-0001zE-C0 for submit@debbugs.gnu.org; Sun, 05 Jan 2025 02:45:21 -0500 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:55157) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tULK3-0001yd-DO for 73404@debbugs.gnu.org; Sun, 05 Jan 2025 02:45:20 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 44F891C0002; Sun, 5 Jan 2025 07:45:09 +0000 (UTC) In-Reply-To: <875xmumpzv.fsf@mail.linkov.net> (Juri Linkov's message of "Sat, 04 Jan 2025 19:46:12 +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:298506 Archived-At: --=-=-= Content-Type: text/plain > The minimal change that doesn't require updating > all existing definitions of treesit-thing-settings, > is just to add an exception for 'list': > [...] > @@ -3618,7 +3618,7 @@ treesit_traverse_validate_predicate (Lisp_Object pred, > - else if (FUNCTIONP (pred)) > + else if (FUNCTIONP (pred) && !BASE_EQ (pred, Qlist)) I admit that hard-coding one symbol is not the right thing to do. So here is a better patch that checks for the symbol property: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=treesit-predicate.patch diff --git a/lisp/treesit.el b/lisp/treesit.el index e643eb48654..169607b150e 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -2516,6 +2516,8 @@ treesit-forward-sexp-list (treesit--scan-error pred arg))) (setq cnt (- cnt inc))))) +(put 'list 'treesit-predicate t) + (defun treesit-forward-list (&optional arg) "Move forward across a list. What constitutes a list is determined by `sexp-list' in diff --git a/src/treesit.c b/src/treesit.c index b3214dad836..4d2cd45e1b2 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -3618,7 +3618,7 @@ treesit_traverse_validate_predicate (Lisp_Object pred, } if (STRINGP (pred)) return true; - else if (FUNCTIONP (pred)) + else if (FUNCTIONP (pred) && !(SYMBOLP (pred) && Fget (pred, Qtreesit_predicate))) return true; else if (SYMBOLP (pred)) { @@ -3722,7 +3722,7 @@ treesit_traverse_match_predicate (TSTreeCursor *cursor, Lisp_Object pred, const char *type = ts_node_type (node); return fast_c_string_match (pred, type, strlen (type)) >= 0; } - else if (FUNCTIONP (pred)) + else if (FUNCTIONP (pred) && !(SYMBOLP (pred) && Fget (pred, Qtreesit_predicate))) { Lisp_Object lisp_node = make_treesit_node (parser, node); return !NILP (CALLN (Ffuncall, pred, lisp_node)); @@ -4333,6 +4333,8 @@ syms_of_treesit (void) DEFSYM (Qtreesit_invalid_predicate, "treesit-invalid-predicate"); DEFSYM (Qtreesit_predicate_not_found, "treesit-predicate-not-found"); + DEFSYM (Qtreesit_predicate, "treesit-predicate"); + DEFSYM (Qor, "or"); #ifdef WINDOWSNT --=-=-=--