Received: (at 60655) by debbugs.gnu.org; 9 Jan 2023 12:29:18 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 09 07:29:18 2023 Received: from localhost ([127.0.0.1]:35966 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pErHB-0005n7-NI for submit <at> debbugs.gnu.org; Mon, 09 Jan 2023 07:29:18 -0500 Received: from out-4.mta0.migadu.com ([91.218.175.4]:34220) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <theo@HIDDEN>) id 1pErH9-0005mv-MI for 60655 <at> debbugs.gnu.org; Mon, 09 Jan 2023 07:29:16 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1673267354; 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=7hMMt8sFthqDgWH4qtbi0FFipQpYkix4QrfUSZdZz6E=; b=yRA6pkT+ioTuZSI0HGgih5SAr6Xw+WAh447Ix0EXwvOVGlk2taj7KZ8V5LftknwvSinXtm g9wLjKdPhyy60BkmKwyNaIL0buA5db8QkZzQQaTdWlRC10BvLUrW+eTPhicTJme6rrxMWA wG3klI6j7NEUj8riIYPfWRTYkSsiQHcMvPKU+y4qNMT04RncZjI3xCIARlR6UK0TD1ivxd tI/AEpVzOTSrjDzhsl4q6mEbDsLbsM9ClfSO+ti7oJos5c/Ff+NV9S0+VbGwV1wAoCuNMw H9hRIx6twNctBsdULYFsNK4ZyA5LC6W9hrnKaIpeGhaT+pXO5pmSu8z70PXNXw== From: Theodor Thornhill <theo@HIDDEN> To: Mickey Petersen <mickey@HIDDEN> Subject: Re: bug#60655: 30.0.50; tree-sitter: `treesit-transpose-sexps' is broken. In-Reply-To: <878ricjdee.fsf@HIDDEN> References: <87r0w5jo0i.fsf@HIDDEN> <87sfgkgqlj.fsf@HIDDEN> <878ricjdee.fsf@HIDDEN> Date: Mon, 09 Jan 2023 13:29:12 +0100 Message-ID: <87cz7nuc13.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60655 Cc: 60655 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Mickey Petersen <mickey@HIDDEN> writes: > Theodor Thornhill <theo@HIDDEN> writes: > >> Mickey Petersen <mickey@HIDDEN> > 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? >> > > This is a hard problem. I'm building the self-same in Combobulate, so > when I saw this implementation I saw a well-trodden path by myself. > There's a lot of subtlety to it, and it is not immediately possible to > accurately gauge the right things to swap with simple (or not so > simple) sibling transpositions. > > Using a defined list is better, but with the caveat that it requires manual > intervention per mode. This is a really tricky thing to build well. Yeah, but I guess that is a sensible change. It isn't easy, no, so I'm open for suggestions and improvements. IMO an improvement would be to increase the likelihood that a transpose-sexps will still be valid code. I don't really think it is useful to do things like "def foo() -> foo def()" because that is nonsensical code, and is covered by transpose-words anyway. To me a _more_ sensible approach here would be to transpose the defun at point with the next one, as they are usually interchangeable. I am looking into such an improvement, and have been for a while. > > > >>> 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. >> > > The old behaviour was consistent. It had a simple *modus operandi*: > swap two things around point. As someone who has used `C-M-t' for > decades, I know what it'll do in pretty much all situations, because I > know what `C-M-k` and `C-M-f/b` do at all times. It may be consistent, but imo it is too close to transpose-words, and too likely to create useless code in non-lisp languages. > > Neither approach is great if you holistically approach this task as > "making it correct at all times", and it is easy to confect scenarios > that result in something that is semantically wrong, but syntactically > correct; something that is plain wrong, both semantically and > syntactically; and something that is occasionally correct. > I see what you mean, but to me semantically _and_ syntactically correct is the benefit we should pursue when we actually have the parse tree. The current implementation will semantically correct in many interesting cases, such as the one I outlined, and is a huge improvement to the current "transpose-words"-like behavior. > 'Like' siblings are an easy way out of this mess with the caveat, as > you'll see, but now you need to carefully pluck the right nodes from > the tree! > > Consider the node type `pair' in a dict in Python. They are easily transposable for > that very reason, notwithstanding the anonymous "," node betwixt them. > > That is why Combobulate has a list of stuff that it can safely > transpose, and for everything else it defaults to the "classic" > transpose. > Yeah, such an approach seems reasonable, and there is already precedence in defining such "things" in Emacs. As for the default fallback, I'll see what I can do in the "treesit-transpose-sexps" function. The machinery in transpose-subr and friends is a little finicky, so to adhere to that mechanism isn't the easiest thing. >>> >>> Worse, it's not possible to revert to the old behaviour (see >>> bug#60654) >>> >>> > > Thanks for fixing that! > No problem - hopefully it is installed pretty soon. Theo
bug-gnu-emacs@HIDDEN
:bug#60655
; Package emacs
.
Full text available.Received: (at 60655) by debbugs.gnu.org; 9 Jan 2023 08:55:22 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 09 03:55:22 2023 Received: from localhost ([127.0.0.1]:35734 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pEnwA-0005xe-7u for submit <at> debbugs.gnu.org; Mon, 09 Jan 2023 03:55:22 -0500 Received: from mail-lo2gbr01on2120.outbound.protection.outlook.com ([40.107.10.120]:22400 helo=GBR01-LO2-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mickey@HIDDEN>) id 1pEnw5-0005xH-A9 for 60655 <at> debbugs.gnu.org; Mon, 09 Jan 2023 03:55:20 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O5nAmZh821eBbKYftRya1iAzbab5jPOPryqsHdEKNug5vRboVzibJEl+h/vDVvgVlew7iZhtep+QGXQBo5eRRrRuAxcraxEkrmq/K0+SzjOoBQs4fSnlpvbLz6rlZARslRlVa15jXDDLuzcbTY0LiTclD+LPmdI6ajEap0NheciGf3MSe1ZtGoRhBvTsao0hSQtOC+hVobcbwg5skdpael+naELQnp0wnHQd8on2/rGQI1aEknVD5McbeQtskC6o/WaompXLE3ThDwtEBqWGQzF+TC/SLlFqHNRsi8Nur1PmsKG9obThiInWtRR1lnLe08ZQ94oEXAryeEinC7at8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8qtW1v0do1k44lg4gSAnGPu16dlrd26mOFRuGgbNbbs=; b=nJgtaYE0t+DopEMZNHUHRqErL3XZdqywKarhd2g93YTe2WHWaC967b75Q0L52jMtyh8uqcyaH+MwzkJpXVwj+ZAJ6Dq56XYe6E+o14/WksZzLmV95d+n6mBIgYEqlK/pg76P9xfPwu3FbZrp4WUMHnQw/CdRiOeGItDLIBqlsSmv4Ui+k0ecW1Ep/YdZrSrH2XBcxc8j4CJu4vOaOb1l88pOMKMaca/MeXqRklLavlH2MhMptCaSBRDobAC9Xn5JLfpdJBDxqJn9FbBFsMaew+43bgP9wsBZG67zqehNxLCnIJY+9jcRb9qx0LlaNKnmRgyhPduJuHqc5Eu36hKxog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 178.79.136.144) smtp.rcpttodomain=debbugs.gnu.org smtp.mailfrom=masteringemacs.org; dmarc=pass (p=none sp=none pct=100) action=none header.from=masteringemacs.org; dkim=pass (signature was verified) header.d=masteringemacs.org; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semantical.onmicrosoft.com; s=selector1-semantical-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8qtW1v0do1k44lg4gSAnGPu16dlrd26mOFRuGgbNbbs=; b=GI5OjQpkKJmd1D2TtoXXA0yf0BdlmLK2v2Y/L58O4vekiQv9ZJYjmmJgzqNaJMnHU2tkqtmbgQLBaXYMeoQvSUJXB+CLad3ZioTTgc+Dpecuuyb6tAsene14mgTuz/xPfpp2JloW4pcrPIZrrMTqFA6IQ/UWVX3oFNvOORyJou4= Received: from LO4P123CA0346.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18d::9) by LO6P265MB6542.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2d2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Mon, 9 Jan 2023 08:55:10 +0000 Received: from CWLGBR01FT036.eop-gbr01.prod.protection.outlook.com (2603:10a6:600:18d:cafe::7f) by LO4P123CA0346.outlook.office365.com (2603:10a6:600:18d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Mon, 9 Jan 2023 08:55:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 178.79.136.144) smtp.mailfrom=masteringemacs.org; dkim=pass (signature was verified) header.d=masteringemacs.org;dmarc=pass action=none header.from=masteringemacs.org; Received-SPF: Pass (protection.outlook.com: domain of masteringemacs.org designates 178.79.136.144 as permitted sender) receiver=protection.outlook.com; client-ip=178.79.136.144; helo=semantical.co.uk; pr=C Received: from semantical.co.uk (178.79.136.144) by CWLGBR01FT036.mail.protection.outlook.com (10.152.40.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Mon, 9 Jan 2023 08:55:09 +0000 Received: by semantical.co.uk (Postfix, from userid 5001) id AD7CF114003; Mon, 9 Jan 2023 08:55:08 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=masteringemacs.org; s=masteringemacs.org; t=1673254508; bh=yfexhumUbs5QWkcdZBhYtaOdsyUGEKisNU9BGXZSb88=; h=References:From:To:Cc:Subject:Date:In-reply-to:From; b=n3L07HjPowm/Cyv+yCRPSuQGfpBu50t5VbRV7KUCC2T6BMawzYd9/7N1wYBWUdZfM 9G2ueZNCYff9ATg/y6WsBE0lWlGDEUoEHq1coNvKW3uVNzaaW6mUoNN6ossr58bIVi 5d2orm7Y3mDLoV9dzse9p/NvsUvXaRE1z7uNmMa4= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on semantical.co.uk X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_RECEIVED, NO_RELAYS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 References: <87r0w5jo0i.fsf@HIDDEN> <87sfgkgqlj.fsf@HIDDEN> User-agent: mu4e @VERSION@; emacs 30.0.50 From: Mickey Petersen <mickey@HIDDEN> To: Theodor Thornhill <theo@HIDDEN> Subject: Re: bug#60655: 30.0.50; tree-sitter: `treesit-transpose-sexps' is broken. Date: Mon, 09 Jan 2023 08:48:04 +0000 Organization: Mastering Emacs In-reply-to: <87sfgkgqlj.fsf@HIDDEN> Message-ID: <878ricjdee.fsf@HIDDEN> Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLGBR01FT036:EE_|LO6P265MB6542:EE_ MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: e7cd996d-a0e6-498e-a3c5-08daf21f3637 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m/qxfnF9g0SmeZZPJHVQLLNxCrf54eAhkaQ65y/CVK62dfi5Jw4cG9bw7bUwzheqIvUxkeU8l5t+JJ1PTUumLgcIMhxxTPBejKAZjj7j3cPDdW1vmajxqf3Fk0a7ZXOcU0BqJtB18ipmgvi25umS9JKu2Fd9Uc+bvrHHLugcl3M+GZQnHn3qHiV1lwpM9QDp8bATjA0TK+nv4Wf8c8hP82eh3tM/TApajLNjY8RhYv4FGL3HtaaUNvQ6b+n62LHChxOgebhqyFHTqEoRthtMoSWsKKDpUVAewnt4amFzrHnqfVD+/qOHKYxFRtZSy/VJXVwdyj5qeLAwghEQpF6Z/IM5v81q3l/4xnvLgC/RHCXPrH0B4FUJvlna+x3pPD3lZwRzm33kEoVquuLYclg8zlCy9A00LJOhCgUEVZtOtfNUq9VboMFLF0y/RUAtfoX6YETIuw7DvGovnOKh0OUMyIsPxkfK9Lo93//8cgLltT8L9r83zFYPyjmtMQH9OmIh9v77NNK1KkdAsmfAjv25M9fobmf4ieDVz0fRiQS/HKukFv/J0YaVDn01M/e7YxLgHbj6ZeDsdqyOIf8V3/q+YCnIz9aFk2u0LdkjJvj/XOYeYIq6xMXxgZ+dvA2woytai4tg+yRMM9pHMESYx5ZeY3YJ2u3eYbXknF2LeOBpmW/ANVh7jMRmM6+ivxYVeHcmsUxyvUrbvTv500UmMAjwEhyneJLaDmDpDbmImoj3rE0WOy96eoFRM91RTIU4CD5LSVGxJXRNBrRE3uDolmAGmQ== X-Forefront-Antispam-Report: CIP:178.79.136.144; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:semantical.co.uk; PTR:semantical.co.uk; CAT:NONE; SFS:(13230022)(346002)(396003)(376002)(136003)(39830400003)(451199015)(46966006)(36840700001)(36860700001)(6666004)(7596003)(7636003)(356005)(2906002)(478600001)(2616005)(26005)(36916002)(186003)(6266002)(5660300002)(316002)(40480700001)(83380400001)(8936002)(6862004)(82310400005)(36756003)(42186006)(86362001)(41300700001)(47076005)(70586007)(70206006)(8676002)(336012)(4326008)(38230200001)(81973001)(14776008)(79816003); DIR:OUT; SFP:1102; X-OriginatorOrg: masteringemacs.org X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2023 08:55:09.3605 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e7cd996d-a0e6-498e-a3c5-08daf21f3637 X-MS-Exchange-CrossTenant-Id: a4e27e3d-bab0-45e8-8942-e64cf9fbd34f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a4e27e3d-bab0-45e8-8942-e64cf9fbd34f; Ip=[178.79.136.144]; Helo=[semantical.co.uk] X-MS-Exchange-CrossTenant-AuthSource: CWLGBR01FT036.eop-gbr01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO6P265MB6542 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 60655 Cc: 60655 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Theodor Thornhill <theo@HIDDEN> writes: > Mickey Petersen <mickey@HIDDEN> > 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? > This is a hard problem. I'm building the self-same in Combobulate, so when I saw this implementation I saw a well-trodden path by myself. There's a lot of subtlety to it, and it is not immediately possible to accurately gauge the right things to swap with simple (or not so simple) sibling transpositions. Using a defined list is better, but with the caveat that it requires manual intervention per mode. This is a really tricky thing to build well. >> 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. > The old behaviour was consistent. It had a simple *modus operandi*: swap two things around point. As someone who has used `C-M-t' for decades, I know what it'll do in pretty much all situations, because I know what `C-M-k` and `C-M-f/b` do at all times. Neither approach is great if you holistically approach this task as "making it correct at all times", and it is easy to confect scenarios that result in something that is semantically wrong, but syntactically correct; something that is plain wrong, both semantically and syntactically; and something that is occasionally correct. 'Like' siblings are an easy way out of this mess with the caveat, as you'll see, but now you need to carefully pluck the right nodes from the tree! Consider the node type `pair' in a dict in Python. They are easily transposable for that very reason, notwithstanding the anonymous "," node betwixt them. That is why Combobulate has a list of stuff that it can safely transpose, and for everything else it defaults to the "classic" transpose. >> >> Worse, it's not possible to revert to the old behaviour (see >> bug#60654) >> >> Thanks for fixing that! Kind regards, Mickey. > > Right. > > Thanks, > Theo
bug-gnu-emacs@HIDDEN
:bug#60655
; Package emacs
.
Full text available.Received: (at 60655) by debbugs.gnu.org; 9 Jan 2023 06:38:22 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 09 01:38:22 2023 Received: from localhost ([127.0.0.1]:35627 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pElnZ-0002Qj-Nk for submit <at> debbugs.gnu.org; Mon, 09 Jan 2023 01:38:22 -0500 Received: from out2.migadu.com ([188.165.223.204]:38134) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <theo@HIDDEN>) id 1pElnX-0002QZ-2u for 60655 <at> debbugs.gnu.org; Mon, 09 Jan 2023 01:38:19 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN 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== From: Theodor Thornhill <theo@HIDDEN> To: Mickey Petersen <mickey@HIDDEN> Subject: Re: bug#60655: 30.0.50; tree-sitter: `treesit-transpose-sexps' is broken. In-Reply-To: <87r0w5jo0i.fsf@HIDDEN> (Mickey Petersen's message of "Sun, 08 Jan 2023 10:53:33 +0000") References: <87r0w5jo0i.fsf@HIDDEN> Date: Mon, 09 Jan 2023 07:38:16 +0100 Message-ID: <87sfgkgqlj.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 60655 Cc: 60655 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Mickey Petersen <mickey@HIDDEN> > 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
bug-gnu-emacs@HIDDEN
:bug#60655
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 8 Jan 2023 10:53:48 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 08 05:53:48 2023 Received: from localhost ([127.0.0.1]:59993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pETJE-00042H-8b for submit <at> debbugs.gnu.org; Sun, 08 Jan 2023 05:53:48 -0500 Received: from lists.gnu.org ([209.51.188.17]:53070) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mickey@HIDDEN>) id 1pETJC-000429-BN for submit <at> debbugs.gnu.org; Sun, 08 Jan 2023 05:53:46 -0500 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 <mickey@HIDDEN>) id 1pETJC-0004e2-33 for bug-gnu-emacs@HIDDEN; Sun, 08 Jan 2023 05:53:46 -0500 Received: from mail-cwlgbr01on2139.outbound.protection.outlook.com ([40.107.11.139] helo=GBR01-CWL-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <mickey@HIDDEN>) id 1pETJ6-00069r-J1 for bug-gnu-emacs@HIDDEN; Sun, 08 Jan 2023 05:53:45 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hj427ztQXYm+xTU81o0GJFSv4C1qz2G8JzirI7o+F0iB7RYhPIMQ8HLcUvIJUVpowbaegqud1PjfPjJ7oS+EM6ysFRgIwdGUuZ77AfYjhQYHscRgQ7HpPK12QFCNNowFD2+fz+wbABL1l7sY0h6GNTntthjOvNqzPUyCIMZvRj0JjHLIGzroPHCs6q8U7y4wU+JGzHat0FxTHXC6WbbquGI2IUr0Zanm88dWulI/GlFdo99/EKPKkMPLRHmttPQnECFAXBLmBWcDiHm71RNIX377swh/ycmhKPYchaVJ2ZAkkj764zqFKrmkMs2gkjJb94mDlYhTtGEzD/qLnyQhKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZZ+8dUst+aCSYYu26M8+ezdzwj7AFIoMoWq7Yk0rxM0=; b=bhL2fvfBNvfNQDlh8EcidR7570VcjJWD46CFcGs+9lJeOoHkb4GoV2OHSFzK/6oMt1A/0Kns/AT+4Dd8r1FgWZvag/XDifJZbmpFD8F9zMK9KP3Lm5Ex3ej+MWDhXc3F5nuXDU9BLBXKdVNITrfDD8lAfXWqKA4yv5vYmEJMhrPqtYqxpt34pRn4b9VVheBWA5lxpa8kGiAwymed8Dpsr1EWVOoEs4l3RcIqUeOPLVz9rP2h7Sq5Qn4lHQoBU9eUZW/1cEgNYQM3umPj+Q7L/9ssnlzEc/4WDTUryqMFF6RUDur8Gjzq5FhL15CmkXbIRyxa/g2hITLFkRnZFSVJ0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 178.79.136.144) smtp.rcpttodomain=gnu.org smtp.mailfrom=masteringemacs.org; dmarc=pass (p=none sp=none pct=100) action=none header.from=masteringemacs.org; dkim=pass (signature was verified) header.d=masteringemacs.org; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semantical.onmicrosoft.com; s=selector1-semantical-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZZ+8dUst+aCSYYu26M8+ezdzwj7AFIoMoWq7Yk0rxM0=; b=bDqTFmhfM+8RiNUfFCl+TzEEYGeowD5b8DFxFPYqdxDTmosTMQz0g98fHWm3RkQjPVz1f8xMgVzE4UCDzrghattycl/jv+nX+L449qALZWskfsnMfoOoHeAeBOOn0eo1DlhCRoY/GC68iqYyF0Lawmef/YZn2ycT1L7P16Tjb9A= Received: from LO6P123CA0025.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:313::18) by LO4P265MB6252.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:27f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Sun, 8 Jan 2023 10:53:36 +0000 Received: from CWLGBR01FT035.eop-gbr01.prod.protection.outlook.com (2603:10a6:600:313:cafe::ab) by LO6P123CA0025.outlook.office365.com (2603:10a6:600:313::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Sun, 8 Jan 2023 10:53:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 178.79.136.144) smtp.mailfrom=masteringemacs.org; dkim=pass (signature was verified) header.d=masteringemacs.org;dmarc=pass action=none header.from=masteringemacs.org; Received-SPF: Pass (protection.outlook.com: domain of masteringemacs.org designates 178.79.136.144 as permitted sender) receiver=protection.outlook.com; client-ip=178.79.136.144; helo=semantical.co.uk; pr=C Received: from semantical.co.uk (178.79.136.144) by CWLGBR01FT035.mail.protection.outlook.com (10.152.40.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5966.17 via Frontend Transport; Sun, 8 Jan 2023 10:53:36 +0000 Received: by semantical.co.uk (Postfix, from userid 5001) id 99D8D114002; Sun, 8 Jan 2023 10:53:35 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=masteringemacs.org; s=masteringemacs.org; t=1673175215; bh=JLQXXjFESZWQRpsB0zslI5WMkKM+85yk5SAcHgyDWqQ=; h=From:To:Subject:Date:From; b=ICoxkyrCMVewo2DANb7o+SNVfKIg1VOstEjc5s5cYOoBTI3xCTxeFvohjOlJtrpeE U8++ZburjzJLxWuJXzCnQDgmKIKGB8HWMMWzQ8Ygzt4xDCXsgFv1xd469w+2lGbIxa pQh5w5mHgQPgaxbI/+rA5n0OPuXQ2hj6+ccQFd0E= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on semantical.co.uk X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_RECEIVED, NO_RELAYS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 From: Mickey Petersen <mickey@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: 30.0.50; tree-sitter: `treesit-transpose-sexps' is broken. Date: Sun, 08 Jan 2023 10:53:33 +0000 Message-ID: <87r0w5jo0i.fsf@HIDDEN> Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLGBR01FT035:EE_|LO4P265MB6252:EE_ MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: c3532b31-297f-48ae-4688-08daf16697b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9vwaoH2VDmltd4hzl6F0A05dvKGXFo97fAPQ7BTyIjDpq7UBbU1R2bS+DQU201nxMjtIiRaWCMDBC+Olq2jYe/C3uGC9xy6BLynnx8TudSfVsb8QD1Pt/D5sGmjZGElm3OYRUP21tDYUmZMAkog9qYDQ9NwHYdLSoKfywGrJH/rTvexE1b12cBbWxTk1/ydR2A4+ihGA5WUWhs7iPMikqRRU+yE+6ETu3vWqYGEIN5+LkXqYigMnaxsg+9KCJhRX1KIemSEqGoHUwi1qv4u2mfIosqPfROOvSmqiaWxGgWo9GSRDNosUXWmZGNTtaTaByUqu7SMoESMIakTXlpr+tVJTEdA5FBXep6qSjs9REXil50vJrTBySpiAKmJnFtpOuXeaOPeClh5Wug9s6FMcJXPRacEB1XwoiDMGPy3dzT8+PD3LC9W9iq8wUViJJ07W5maxK4t2QlKcbexKX/PvvRbxZkIRfHWaeuEcC5ksDYZPKxwQBa+2yE10LacS8ZN8O3Z95J234W/1vy6llShikPnhCIi3ZXmGIAUGoFnUSlaQt4QDRZNv/PXjgxt/6wbyxhAstdVM7vg8vRiHG0CwjarYzeWFlEVXalxj47qt6pJFzpsl8YH4weERNeKSuYHnur8vMsA4j9OIDgi3cu1fQ6RoKmn9bUjGuFraIp90hGE7H7R+LdzVePmuzFzzyzGBz4qWjVGJHgtyQ9E4At3nQ+KkXT7gOV+eds10vEOcYlcLKpE+b4NpvV9EY8REw0lIyYOa0mpffjPr9TlrJP7K4g== X-Forefront-Antispam-Report: CIP:178.79.136.144; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:semantical.co.uk; PTR:semantical.co.uk; CAT:NONE; SFS:(13230022)(346002)(396003)(136003)(376002)(39830400003)(451199015)(36840700001)(46966006)(36860700001)(7596003)(7636003)(356005)(2906002)(478600001)(2616005)(186003)(6266002)(26005)(5660300002)(316002)(40480700001)(82310400005)(8936002)(36756003)(42186006)(86362001)(41300700001)(47076005)(336012)(8676002)(70586007)(70206006)(6916009)(38230200001)(81973001)(14776008)(79816003); DIR:OUT; SFP:1102; X-OriginatorOrg: masteringemacs.org X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2023 10:53:36.0075 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3532b31-297f-48ae-4688-08daf16697b5 X-MS-Exchange-CrossTenant-Id: a4e27e3d-bab0-45e8-8942-e64cf9fbd34f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a4e27e3d-bab0-45e8-8942-e64cf9fbd34f; Ip=[178.79.136.144]; Helo=[semantical.co.uk] X-MS-Exchange-CrossTenant-AuthSource: CWLGBR01FT035.eop-gbr01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO4P265MB6252 Received-SPF: pass client-ip=40.107.11.139; envelope-from=mickey@HIDDEN; helo=GBR01-CWL-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.4 (--) 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. 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. Worse, it's not possible to revert to the old behaviour (see bug#60654) In GNU Emacs 30.0.50 (build 6, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2023-01-02 built on mickey-work Repository revision: c209802f7b3721a1b95113290934a23fee88f678 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12013000 System Description: Ubuntu 20.04.3 LTS
Mickey Petersen <mickey@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#60655
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.