From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#60655: 30.0.50; tree-sitter: `treesit-transpose-sexps' is broken. Date: Mon, 09 Jan 2023 07:38:16 +0100 Message-ID: <87sfgkgqlj.fsf@thornhill.no> References: <87r0w5jo0i.fsf@masteringemacs.org> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2116"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60655@debbugs.gnu.org To: Mickey Petersen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 09 07:39:32 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 1pEloi-0000Kq-2G for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 09 Jan 2023 07:39:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEloH-00081p-Qn; Mon, 09 Jan 2023 01:39: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 1pEloE-00081E-HU for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2023 01:39:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEloE-0002Nm-8m for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2023 01:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pEloE-0002S2-4l for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2023 01:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 09 Jan 2023 06:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60655 X-GNU-PR-Package: emacs Original-Received: via spool by 60655-submit@debbugs.gnu.org id=B60655.16732463029349 (code B ref 60655); Mon, 09 Jan 2023 06:39:02 +0000 Original-Received: (at 60655) by debbugs.gnu.org; 9 Jan 2023 06:38:22 +0000 Original-Received: from localhost ([127.0.0.1]:35627 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pElnZ-0002Qj-Nk for submit@debbugs.gnu.org; Mon, 09 Jan 2023 01:38:22 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]:38134) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pElnX-0002QZ-2u for 60655@debbugs.gnu.org; Mon, 09 Jan 2023 01:38:19 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1673246298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hZr47NKwMOI+PWxgj9vjkTRXxqHTsJJO4f6s9NkMBhE=; b=e5jRgoUfzffWny6MCeHnShGbx0aEq2phh7RB/FzRvDWjSyYlZkWnwQTS1Ty3a68/XFN/u1 63ZOXOmNepS3dQXX2xKuZM3v11gqhjuidP8Oqu3A8M5AxjPN9uTSaMISgW9AcVFm3LEPqz Ia6cA5m2sQyaqsQmUSC5jtx+GOmhqSGcEZG6zhhBUvF6vLK7epBDzmOVXRiR3Dnluhy/hT VIxRVs2idjYjho1ak8l65hSsppGxFr3153UiywB4U60xqIU8D4BEIavJU9QzInFIODh2zE fKyZJ6AqUQ9lmso6bORLbeYVeqdAg3d2b/MTEvWaXjEcasmnub0qlsjgMUwumA== In-Reply-To: <87r0w5jo0i.fsf@masteringemacs.org> (Mickey Petersen's message of "Sun, 08 Jan 2023 10:53:33 +0000") X-Migadu-Flow: FLOW_OUT 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:252991 Archived-At: Mickey Petersen > The tree-sitter-enabled function, `treesit-transpose-sexps', that is called by transpose-sexps, is broken. > > It uses a naive method of sibling adjacency to determine > transpositions. But it is unfortunately not correct. > > Python: > > > def -!-foo(): > pass > > Turns into this with `C-M-t': > > def ()foo: > pass > > But it ought to be: > > foo def(): > pass > > > It's swapping two siblings that are indeed adjacent in the tree, but > not on screen, which is confusing and a regression from its previous > behaviour. > I can try to make transpose-sexps rely on only swapping "allowed" node-types? That would be able to keep the new, better function, yet still disallow these syntax-breaking transposes. What do you think? > You could make a cogent argument that both approaches are wrong from a > syntactic perspective, but I think that misses the broader point that > `C-M-t' now does something errant and unexpected. I don't really see how "foo def():" is any better at all. We gain some great improvements with this "naive" method - namely: if 5 + 5 == 10 then 10 else 100 + 100. If point is on the else the 100 + 100 wil be swapped by 10, but the old behavior will be broken. > > Worse, it's not possible to revert to the old behaviour (see > bug#60654) > > Right. Thanks, Theo