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#62158: treesit-end-of-defun error Date: Tue, 21 Mar 2023 14:26:26 -0700 Message-ID: <8CC10648-87D5-455F-BE3D-43E7A4EC94C5@gmail.com> References: <868rg13y9w.fsf_-_@mail.linkov.net> <48E5D6CC-3249-4A5E-82B6-D3B9BF37D40A@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.400.51.1.1\)) 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="2935"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62158@debbugs.gnu.org, Juri Linkov To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 21 22:27:45 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 1pejWD-0000ZH-Ge for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 21 Mar 2023 22:27:45 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pejVd-0001AU-9O; Tue, 21 Mar 2023 17:27:09 -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 1pejVX-0001AC-Th for bug-gnu-emacs@gnu.org; Tue, 21 Mar 2023 17:27:04 -0400 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 1pejVW-0007XI-OZ for bug-gnu-emacs@gnu.org; Tue, 21 Mar 2023 17:27:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pejVW-0002w8-G2 for bug-gnu-emacs@gnu.org; Tue, 21 Mar 2023 17:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 21 Mar 2023 21:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62158 X-GNU-PR-Package: emacs Original-Received: via spool by 62158-submit@debbugs.gnu.org id=B62158.167943400711263 (code B ref 62158); Tue, 21 Mar 2023 21:27:02 +0000 Original-Received: (at 62158) by debbugs.gnu.org; 21 Mar 2023 21:26:47 +0000 Original-Received: from localhost ([127.0.0.1]:32781 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pejVG-0002va-RE for submit@debbugs.gnu.org; Tue, 21 Mar 2023 17:26:47 -0400 Original-Received: from mail-pj1-f48.google.com ([209.85.216.48]:36558) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pejVE-0002vH-GS for 62158@debbugs.gnu.org; Tue, 21 Mar 2023 17:26:45 -0400 Original-Received: by mail-pj1-f48.google.com with SMTP id o6-20020a17090a9f8600b0023f32869993so17785417pjp.1 for <62158@debbugs.gnu.org>; Tue, 21 Mar 2023 14:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679433998; 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=TLa0LDB51soRq3eDo+VNawEAx/DUPnB4TfHuQ+pxZek=; b=g21ZOaJ3aIVhAZI2NFed+HQo/HL4nh0jKEf4J9fiYsuLXhUbtylA8MJAC2SUm3nVrl OALpKWsfmiTQqwJT3Nmbc71PVNISsTorUJRlM+6ih3YvgSCOCSMJHB8URjkISilrtK2k +hikTNc7LSxYDZ5Ib7XHjahjcBR07n0jhZ2DOvbZIzOADEHsopsLZ3gKCHRIoHeeQBmS GK30o+ZM94VHc8S4v8iEQ0+Vjvrp++ivhF6E7ZjYkUr8r3F0Mg4ewpY4FmR8TDkzlUrj wSJKhD5ISY/6khcWa+vijn6MsBpbuODad6a+RJraGvKgMNKq4BBFscyj+C45mb82384v jraw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679433998; 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=TLa0LDB51soRq3eDo+VNawEAx/DUPnB4TfHuQ+pxZek=; b=42ZdF4Nz3mIGeIoixDr5zGbk99Ty/oxN/1QNqylQg0PHumiuYN1zyXRZwvNxMIwszY IUbOvml1J2NYh9x6Ww7/fEi42brWsmmtQy+nsnTRMnwbeiQd83wOoiYLa37hBDA8QWSt qGmGRmR93w1mttvj5AHurrqE2XXGsPbK+fqyy3XZz2XvTXkzYSSgHNpMLGQPVy86j1z1 siImeQmC2xicoKTJBMgoyv6ccbBBF0TRBpM1YemysmVIWNJbNzYcAsJwrX7WiYHM7SLr 9i2HOICnv9xIADOEb/Ev0YnTbaa5VVMyQRg23BkdGhYlQNKJHPMV5lXIe+znw+qmuC0N g3dQ== X-Gm-Message-State: AO0yUKUqfwJpJ3tzaovj8UltBbJeQZVL1Q1c8xzciAsNOvjfDwNpFBai 5cxnnlRdgOmBGL1fVK6J+qU= X-Google-Smtp-Source: AK7set+w0yphtqPMH11rLxbUCp+ysWWP2ZE+ckAG6kPUM1sXQ1qT+dXUewL6U5xAZS94Xn9cv334qg== X-Received: by 2002:a05:6a20:1e46:b0:da:17b4:461a with SMTP id cy6-20020a056a201e4600b000da17b4461amr2509247pzb.32.1679433998280; Tue, 21 Mar 2023 14:26:38 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id b2-20020aa78702000000b00592543d7363sm8718421pfo.1.2023.03.21.14.26.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Mar 2023 14:26:37 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3731.400.51.1.1) 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:258369 Archived-At: > On Mar 20, 2023, at 11:43 AM, Dmitry Gutov wrote: >=20 > On 14/03/2023 00:04, Yuan Fu wrote: >> We tried that initially, but end-of-defun doesn=E2=80=99t have the = notion of nested defuns, which leads to problems when = end-of-defun-function recognizes nested defuns. In the following code >> (defun xxx () >> | >> (defun yyy () ...) >> (defun zzz () ...) >> ) >> If point is at =E2=80=9C|=E2=80=9D and you call end-of-defun, you=E2=80= =99d expect point to move to the end of yyy, but instead it moves to the = end of xxx. That=E2=80=99s because end-of-defun first runs = (beginning-of-defun -1) followed by (end-of-defun 1) to check if the = starting point is in a defun or between two defuns. This is fine in = non-nested defuns, but in this example, the point first goes to the = beginning of xxx, then goes to the end of xxx. And end-of-defun thinks = that we started in a defun and now is at an end of defun, job=E2=80=99s = done, and finishes. >> The plan is to improve end-of-defun to support nested defuns in Emacs = 30. For now we rebind end-of-defun to treesit-end-of-defun. >=20 > That makes sense, thanks! >=20 > I guess one of the things to try is to call end-of-defun-function = first, followed by beginning-of-defun-function. And see if the resulting = position is below the original point. Unfortunately, end-of-defun-function must be called from the beginning = of a defun, according to its docstring. So that won=E2=80=99t do. We got = to upgrade beginning/end-of-defun to support nested defuns. Yuan=