From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu 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: Thu, 26 Sep 2024 00:42:53 -0700 Message-ID: References: <87plox4mtp.fsf@masteringemacs.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35413"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73404@debbugs.gnu.org To: Mickey Petersen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 26 09:44:53 2024 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 1stjBF-00094V-Cp for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Sep 2024 09:44:53 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1stjB0-00012H-6Z; Thu, 26 Sep 2024 03:44:38 -0400 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 1stjAy-00011k-Fe for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2024 03:44:36 -0400 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 1stjAy-00060T-4L for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2024 03:44:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:Date:In-Reply-To:From:Mime-Version:To:Subject; bh=9BYnUuo77WxF5NtFm5j2/xu/bHsG/8PbViQG5Sih8OI=; b=HHteFVQb5qtkmVNoRUYGagc57VD3xMFag/jGSwu+j6eImjWB7WNZv+h1zCIvg9vGMO2ivrDHsNgp2TAzVS89mditgVpGZeqNueRpht8hwWHZ3Sl5GuVl1NFwTqwE0FhgCh5jz1epscTFAVE5kDsPVrRiQrgRcqddPIvoEetgbRPbccKC2o4tphmKOBTRm9J86NjMClqkuo4s4C0xD4eV6kGOpJfh9pJycbUzLAYFipdzmvpOYtafVWEylrI8TJAIHlpaV9VwQ3dqoOTxLqvsx2Y8zJFrajoX3Ne1CINypFZKGbqniEazEgGZtSGYCNfhi5t1oV6A4hZvP/5RFBm50A==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1stjBN-0002E2-TH for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2024 03:45:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Sep 2024 07:45:01 +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.17273366818471 (code B ref 73404); Thu, 26 Sep 2024 07:45:01 +0000 Original-Received: (at 73404) by debbugs.gnu.org; 26 Sep 2024 07:44:41 +0000 Original-Received: from localhost ([127.0.0.1]:50977 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stjB2-0002CY-9l for submit@debbugs.gnu.org; Thu, 26 Sep 2024 03:44:40 -0400 Original-Received: from mail-oo1-f53.google.com ([209.85.161.53]:60588) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stjB0-0002C6-3N for 73404@debbugs.gnu.org; Thu, 26 Sep 2024 03:44:38 -0400 Original-Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-5d5c7f24372so380899eaf.0 for <73404@debbugs.gnu.org>; Thu, 26 Sep 2024 00:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727336585; x=1727941385; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9BYnUuo77WxF5NtFm5j2/xu/bHsG/8PbViQG5Sih8OI=; b=PHfH4WaVdTLKF5Z9uYL8EjgRt6L14004ObwZaRxRELJm2Zc01Wx9PMOLROOZdwX2/0 A7T+4q9TIXQGZH0mgiN7dYiIyOW7yAfo7CiVHjYXBzJw4VOYcAatTx2je8Qyu+yZS+mu njrvUBSex2MYJh/sH+/Qps85B1/HG1jL2uLYQk/OagVdbe8k45+vuooO+usLyaMgowfa 2V1wtOrgupB79NBBDf++H09LwuvjQh3sEq35s9zxS/bphQ2Zer9UosrhliShS9wWOIFV QWS6uhu/BRYooHHylhgCekaIeopkJKpKEegmhxjJia7+tST/Ojp94dNIK055fkVwwDaR qhHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727336585; x=1727941385; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9BYnUuo77WxF5NtFm5j2/xu/bHsG/8PbViQG5Sih8OI=; b=GuFTFajxQiGJkoUDvdFFhXEYS51FZBhYLpZb6lqmJfu7TycRZ4mFssfvrCEuV8TqC3 1KyR5ufu5sHuYjg6xKxmlM2kDMlQvj9qnFBvwXPXBvORY5Yj32+urojC9Pf0TaQ4156y W1CtOsA5MYe8OBkVig//1xQ+ubECXiW6+OldJhhJYBDuCCZGUPBgLSfiUXibrB72wuhf 5iax8ThLNwUfQ8jNgpd+DERgfvwl+XsBIAjhZKieOe5aRLDtyGe1r8hiTpOUOn/RlYg5 bECToQLdLcTHKviW+WKCjWGpinpgVvcnVfKcExstCYsVfbhzfyHCvJ/09AAYoJfJ5hVd hcFg== X-Gm-Message-State: AOJu0YzlDaiK4FEYPdiWZqmRFZnyJ6jefZWOe9ZfcHVS5ISq8XmNinH7 tZh//R5oOIvb9tWUweakGRIAYIpJ+8mtncO2zwqsK1BTSdBBezGh X-Google-Smtp-Source: AGHT+IF4jQdbztoi7KLWdvp62DuuFNB+x91J5LWSCAyafdN48OhRqSnN8mxaWL/9gCpOSIAWdp0Wxg== X-Received: by 2002:a05:6870:8089:b0:25a:eca3:6b5e with SMTP id 586e51a60fabf-286e129f9d1mr4068254fac.9.1727336585205; Thu, 26 Sep 2024 00:43:05 -0700 (PDT) Original-Received: from smtpclient.apple ([2601:646:8f81:6120:b979:1835:aae4:102]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6b7c5c06fsm3760346a12.55.2024.09.26.00.43.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Sep 2024 00:43:04 -0700 (PDT) In-Reply-To: <87plox4mtp.fsf@masteringemacs.org> X-Mailer: Apple Mail (2.3776.700.51) 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:292442 Archived-At: > On Sep 20, 2024, at 10:06=E2=80=AFPM, Mickey Petersen = wrote: >=20 >=20 >=20 > Examples with javascript-mode. It holds for all modes i tested with a > TS equivalent. Let -!- be the starting point and ^N be the subsequent > position after a movement command. >=20 > -!-export const add =3D (a, b) =3D> a + b; >=20 > Repeated `C-M-f' yields >=20 > export const add =3D (a, b) =3D> a + b; >=20 > ^1 ^2 ^3 ^4 ^5 ^6 >=20 >=20 > In other words, it works as it always has. >=20 > Meanwhile, in `js-ts-mode': >=20 > export const add =3D (a, b) =3D> a + b; > ^1 ^2 ^3 ^4 >=20 > =46rom ^1 and back with `C-M-b' >=20 > export const add-!- =3D (a, b) =3D> a + b; >=20 > export const add =3D (a, b) =3D> a + b; > ^1 >=20 > At this point, `C-M-b' no longer goes back. It is stuck. >=20 >=20 > Another example: >=20 > -!-console.log("Addition result:", result1); >=20 > With `C-M-f': >=20 > console.log("Addition result:", result1); >=20 > ^1 ^2 >=20 >=20 > This affects every single -sexp function that uses either > `forward-sexp-function' or `transpose-sexp-function' to do its job. >=20 > Thanks. >=20 I=E2=80=99m aware of this problem and it=E2=80=99s quite inconvenient at = times, but right now I don=E2=80=99t have a good solution for it. Ideas = are welcome. Basically tree-sitter=E2=80=99s sexp movement works on subtrees. It = determines the position of the point in the whole parse tree and goes = forward/back across the next subtree in the parse tree. If there=E2=80=99s= no more sibling subtrees in the same level to move over, sexp movement = stops like in lisp. The parse tree is invisible and often groups token = in unexpected ways, so many times the sexp movement isn=E2=80=99t = intuitive. We might need to add a user option so people can easily turn off = tree-sitter sexp movement, since it isn=E2=80=99t a strict upgrade from = the generic sexp movement=E2=80=94it=E2=80=99s more of a different = flavored sexp movement. Yuan=