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#60894: 30.0.50; [PATCH] Add treesit-forward-sexp Date: Thu, 19 Jan 2023 20:03:11 +0100 Message-ID: <87tu0muz2o.fsf@thornhill.no> References: <875yd428ng.fsf@thornhill.no> <4e2dacb8-31b3-58e2-4987-2d22501c3324@yandex.ru> <87358827ku.fsf@thornhill.no> <847c7696-1884-d801-150e-4589a6c4b0e7@yandex.ru> <87h6woievr.fsf@thornhill.no> <86ee0347-2251-e4b7-1dd0-78949a423053@yandex.ru> <58908185-e09a-7920-553f-b9502d4f49f9@yandex.ru> <7eaf4b3a-cf4d-f0d4-243c-cde50f3d0dfd@yandex.ru> 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="11943"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60894@debbugs.gnu.org, Mickey Petersen , Juri Linkov To: Dmitry Gutov , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 19 20:04:34 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 1pIaD9-0002pm-GK for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 19 Jan 2023 20:04:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIaCx-0007zo-EO; Thu, 19 Jan 2023 14:04:19 -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 1pIaCg-0007xs-DO for bug-gnu-emacs@gnu.org; Thu, 19 Jan 2023 14:04:10 -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 1pIaCg-0001LK-0W for bug-gnu-emacs@gnu.org; Thu, 19 Jan 2023 14:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pIaCf-0005oW-PG for bug-gnu-emacs@gnu.org; Thu, 19 Jan 2023 14:04:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Jan 2023 19:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60894 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 60894-submit@debbugs.gnu.org id=B60894.167415499922296 (code B ref 60894); Thu, 19 Jan 2023 19:04:01 +0000 Original-Received: (at 60894) by debbugs.gnu.org; 19 Jan 2023 19:03:19 +0000 Original-Received: from localhost ([127.0.0.1]:44757 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIaBy-0005nY-Oh for submit@debbugs.gnu.org; Thu, 19 Jan 2023 14:03:19 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]:31849) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIaBv-0005nM-He for 60894@debbugs.gnu.org; Thu, 19 Jan 2023 14:03:17 -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=1674154993; 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=3kBY2Lg/+zgJ74HxgL7+rPT1gpNlLEeb47b12Dc71BM=; b=ALPM/tH54nz3a3GR0te2KMxOxGyzZ6QQTI2Izvtf77UAItS50pSw7sDTk3z+Jd21/0k/td gZsqI1gVGE7HgKkl1GoaLUfUObI6B1zgUxz2Ym/96vDl0NLpgc5E00adeqqOfOuDaxRnED 4ZqmTfoWYZ6CAemL7yN/nXkMzB/IkweDu+q46e1zK6UwFDnEtcYCuBGiiDNffuO0pPSYFg ageodudfRZXRZsFA3rFwMlHIazF/CtXvmgbHKnOxzrWtkKDnzAWtBYQ/DKFa/kED10Si7x nVz8dSKIIXycLcr8Fni7NyS4/oAPgqpHIeI9O0vNAnjQ6nBLMDUK+IyhYomKzA== In-Reply-To: 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:253726 Archived-At: Dmitry Gutov writes: > On 19/01/2023 05:58, Stefan Monnier via Bug reports for GNU Emacs, the > Swiss army knife of text editors wrote: >>>> I think `C-M-u` from within a LaTeX environment was one of the cases >>>> where it misbehaved (tho that one is not using SMIE). >>> Any chance SMIE is doing something different, or something >>> particularly correct? >> >> Could be. Maybe its simplistic approach rules out the bad cases? > > Simplistic meaning one that uses a list of openers and closers? > >>>>> Do you mean a hook like backward-up-list-function, or something smaller? >>>> Something like that. Maybe it could also be used for `expand-region` >>>> and `thing-at-point` kind of purposes maybe and could work even for >>>> treesit nodes that aren't "matching begin..end thingies". >>> A treesit node doesn't need an explicit "end" token, though. >> >> And that's what I want: I want to use successive `C-M-u` (or >> `expand-region`) to consider ever greater subexpressions that include >> the position from which I started and to do that at a fine grain. >> E.g. if I start with point on `b` in: >> >> a + b * c >> >> I'd like to first consider "b" then "b * c" then the whole thing. > > That should be easy enough to do using the provided tree-sitter > framework, just by adding binary nodes to the list of types. > > Whether this behavior is preferable is a matter of opinion, though. My > guess is Ruby users will find it too fiddly, and the end result is that > one will have to press 'C-M-u' more times to get to the same result > (which would usually be to get to the beginning of a block, or a > method). But people can customize it. So I pushed the changes I've made so far, after addressing Elis comments. Let's try it for a while and see how we feel about it going forward. Theo