From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zubarev Dv Newsgroups: gmane.emacs.bugs Subject: bug#66989: 30.0.50; tree-sitter: treesit-defun-at-point wrong behavior in python-ts-mode Date: Wed, 08 Nov 2023 23:37:45 +0300 Message-ID: <2908341699475865@izsosstglkfltgsl.vla.yp-c.yandex.net> References: <87pm0l1qtu.fsf@yandex.ru> <1D1196AE-7E7F-4887-B9FE-4EBA61042A4F@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4976"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 66989@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 08 21:38:48 2023 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 1r0pK3-00016a-Qj for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Nov 2023 21:38:47 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0pJh-000349-T9; Wed, 08 Nov 2023 15:38:25 -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 1r0pJf-00033z-Tk for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2023 15:38:23 -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 1r0pJf-0008GU-LQ for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2023 15:38:23 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r0pKI-0004PF-1E for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2023 15:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Zubarev Dv Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Nov 2023 20:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66989 X-GNU-PR-Package: emacs Original-Received: via spool by 66989-submit@debbugs.gnu.org id=B66989.169947591016895 (code B ref 66989); Wed, 08 Nov 2023 20:39:01 +0000 Original-Received: (at 66989) by debbugs.gnu.org; 8 Nov 2023 20:38:30 +0000 Original-Received: from localhost ([127.0.0.1]:46346 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r0pJm-0004OQ-6N for submit@debbugs.gnu.org; Wed, 08 Nov 2023 15:38:30 -0500 Original-Received: from forward500a.mail.yandex.net ([178.154.239.80]:38780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r0pJi-0004OB-VJ for 66989@debbugs.gnu.org; Wed, 08 Nov 2023 15:38:28 -0500 Original-Received: from mail-nwsmtp-mxback-production-main-74.vla.yp-c.yandex.net (mail-nwsmtp-mxback-production-main-74.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1d:3d26:0:640:beab:0]) by forward500a.mail.yandex.net (Yandex) with ESMTP id B92F061401; Wed, 8 Nov 2023 23:37:45 +0300 (MSK) Original-Received: from mail.yandex.ru (2a02:6b8:c0d:282:0:640:476c:0 [2a02:6b8:c0d:282:0:640:476c:0]) by mail-nwsmtp-mxback-production-main-74.vla.yp-c.yandex.net (mxback/Yandex) with HTTP id WbkPLO3U80U0-vVXJkHLC; Wed, 08 Nov 2023 23:37:45 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1699475865; bh=WWIAZfdIN3ZywkN+6XDTdUgJvAVIjGLwyAkClAnQbuE=; h=Message-Id:References:Date:Cc:Subject:In-Reply-To:To:From; b=SOKN3D2joLWaE5uiPwYF+oLYVkED27q3vHLuOLdecdRejoXHGE6DeVPgNWHdAyVbf qXmsgLezyP0dVm+H+VP3cLEHy2WhU3fZ3DAla8Y3aMQ4ODGp44M9aOd5yDzDlO7vHy EbRo9cCyp5Wp0bqRF69D5hgaW92lwAV0DOhpavWk= Authentication-Results: mail-nwsmtp-mxback-production-main-74.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by izsosstglkfltgsl.vla.yp-c.yandex.net with HTTP; Wed, 08 Nov 2023 23:37:45 +0300 In-Reply-To: <1D1196AE-7E7F-4887-B9FE-4EBA61042A4F@gmail.com> X-Mailer: Yamail [ http://yandex.ru ] 5.0 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:274013 Archived-At: Initially I thought that it is the second definition. It seems to be more intuitive. But after reading code, I was sure its the first case. But I actually don't sure that all three "things" are needed at once. For example, I think for `thing-at-point` only enclosing parent is needed. If parent is nil, it may optionally fallback to the next sibling thing. `treesit--navigate-thing` uses only `parent` and `next` or `prev`. I was playing with creating evil text objects, based on your awesome work with "things". I ended up extracting the second part (;; 2. Find the parent) from `treesit--things-around`. Since I only need to find enclosing parent and I don't want to pay for what I don't use. So it seems no function uses all results from `treesit--things-around`. Maybe it makes sense to decompose `treesit--things-around` into two functions: 1. (treesit--enclosing-thing (pos thing)) - returns node or nil if no enclosing parent 2. (treesit--find-sibling (pos thing dir)) - return sibling node in specified direction. BTW, I've found another unexpected behavior on the same code: 1. python-ts-mode def premain(): pa|ss def main(): pass 2. after (goto-char (treesit--navigate-thing (point) 1 'end treesit-defun-type-regexp)) def premain(): pass def main(): pass| cursor in the end of the second function 3. but if you move cursor to the beginning of pass def premain(): |pass def main(): pass 4. after (goto-char (treesit--navigate-thing (point) 1 'end treesit-defun-type-regexp)) def premain(): pass| def main(): pass This behavior does not affected by the fix proposed in the first message.