From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#62158: treesit-end-of-defun error Date: Mon, 20 Mar 2023 20:43:51 +0200 Message-ID: References: <868rg13y9w.fsf_-_@mail.linkov.net> <48E5D6CC-3249-4A5E-82B6-D3B9BF37D40A@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28554"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Cc: 62158@debbugs.gnu.org To: Yuan Fu , Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 20 19:45:39 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 1peKVm-0007FV-N8 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Mar 2023 19:45:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1peKVG-0003Js-7r; Mon, 20 Mar 2023 14:45:06 -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 1peKVD-0003Ip-FB for bug-gnu-emacs@gnu.org; Mon, 20 Mar 2023 14:45:03 -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 1peKVC-0004y0-PH for bug-gnu-emacs@gnu.org; Mon, 20 Mar 2023 14:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1peKVC-00023S-7U for bug-gnu-emacs@gnu.org; Mon, 20 Mar 2023 14:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Mar 2023 18:45: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.16793378427802 (code B ref 62158); Mon, 20 Mar 2023 18:45:02 +0000 Original-Received: (at 62158) by debbugs.gnu.org; 20 Mar 2023 18:44:02 +0000 Original-Received: from localhost ([127.0.0.1]:56802 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1peKUE-00021m-Gz for submit@debbugs.gnu.org; Mon, 20 Mar 2023 14:44:02 -0400 Original-Received: from mail-wr1-f52.google.com ([209.85.221.52]:34724) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1peKUC-00021A-Sw for 62158@debbugs.gnu.org; Mon, 20 Mar 2023 14:44:01 -0400 Original-Received: by mail-wr1-f52.google.com with SMTP id v1so5268109wrv.1 for <62158@debbugs.gnu.org>; Mon, 20 Mar 2023 11:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679337835; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=wkf5LE3UJQYVyY8O1+rCxwIWR6IxXNopWcWMLT7KQGo=; b=dLacG6LgbJZ4ozFKT+ay2nK0XKRGKGsqF7vt/YgMqB5JZtTE2D8Kt92HPbihIKzc/N oG4w735eC4oCwppdbQMHsMEJPQuRTY25M7/VDcPW5Bz+wVZL5czHGt7wPnzqqXG0CMb3 p38Y706PmZdxfzeKA6nvf/emxmcEkOw4zGUr5ilkzAqN122wZRKhzj2BD2NCYnGn3wgp YIxfI8y6PJdNNOp2/7gXC9rDt7Qe3WMZtjmShX35jOQAAMCqso7alyOeC4rflakVqP+r f4Tjtgz8QGA00GqfqHvHR8AeOwdJAPXt09K1QWxX7quRPqbzzcdSLuVS3O9IG4SOaSRB 6/hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679337835; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wkf5LE3UJQYVyY8O1+rCxwIWR6IxXNopWcWMLT7KQGo=; b=d109VmFfxP5ULRkZxxXoHNHBAh9Gek9B3asl9+zQJMCshhxMyGGUn9Oc900f69w1GY jJpOAil4jVaooRBdr5jebYyLcUmSpzqqxXu8YY+n5nYCuHEl1kWY/hlKfgwNcQx0n0NV aA1qubphDdeuPaEtTds1vIdD1yTjzbWZ+tujlYwWS2rmkFtGpdj0YTLzzPakjlnruaIb kc9/SggnZV1YOVBboaU4/egQP8dyqCOejbPpTawRxgelVOyaEYcSrAea6VGVVyLV0NJa HtJfp2VrpUu5IVZdTBWzn/TkTaA6PJ865yKJyzBuU/G3ZzKFpM8l9i0nQtPMsKXaCEZI 89Pg== X-Gm-Message-State: AO0yUKWy9FxGuWpExwOTTmep6zdlf+ijBEipjyjFBquzotSbgG5KkLcl 5U1/axyr1Jn/lGPJjlzi4fQ= X-Google-Smtp-Source: AK7set/bDFDokmRSeN9K/8C6ZrSBwIVAUfbw/O77F3lvxFqSU+I42/RDuWRzNdyDCq007xvXMww2vw== X-Received: by 2002:a5d:5381:0:b0:2cf:ee3b:950 with SMTP id d1-20020a5d5381000000b002cfee3b0950mr253359wrv.54.1679337834673; Mon, 20 Mar 2023 11:43:54 -0700 (PDT) Original-Received: from [192.168.0.2] ([85.132.229.92]) by smtp.googlemail.com with ESMTPSA id bg7-20020a05600c3c8700b003eb2e33f327sm28962392wmb.2.2023.03.20.11.43.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Mar 2023 11:43:54 -0700 (PDT) Content-Language: en-US In-Reply-To: <48E5D6CC-3249-4A5E-82B6-D3B9BF37D40A@gmail.com> 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:258312 Archived-At: On 14/03/2023 00:04, Yuan Fu wrote: > We tried that initially, but end-of-defun doesn’t 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 “|” and you call end-of-defun, you’d expect point to move to the end of yyy, but instead it moves to the end of xxx. That’s 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’s 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. That makes sense, thanks! 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.