From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Troy Brown Newsgroups: gmane.emacs.bugs Subject: bug#68664: 29.1.50; treesit defun commands broken with nested functions Date: Mon, 22 Jan 2024 18:10:34 -0500 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31222"; mail-complaints-to="usenet@ciao.gmane.io" To: 68664@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 23 00:12:37 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 1rS3T3-0007ue-In for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 23 Jan 2024 00:12:37 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rS3SY-0003RS-Uo; Mon, 22 Jan 2024 18:12:08 -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 1rS3SQ-0003Qp-R5 for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2024 18:11:59 -0500 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 1rS3SQ-0007wT-8m for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2024 18:11:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rS3SU-0002qv-8m for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2024 18:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Troy Brown Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Jan 2024 23:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68664 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.170596506510875 (code B ref -1); Mon, 22 Jan 2024 23:12:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Jan 2024 23:11:05 +0000 Original-Received: from localhost ([127.0.0.1]:41890 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rS3RY-0002pL-U0 for submit@debbugs.gnu.org; Mon, 22 Jan 2024 18:11:05 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:46386) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rS3RU-0002oi-Eu for submit@debbugs.gnu.org; Mon, 22 Jan 2024 18:11:04 -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 1rS3RK-0003Hj-Ib for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2024 18:10:50 -0500 Original-Received: from mail-ej1-f52.google.com ([209.85.218.52]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rS3RI-0007Zr-NQ for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2024 18:10:50 -0500 Original-Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a30359b97a8so182347766b.0 for ; Mon, 22 Jan 2024 15:10:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705965046; x=1706569846; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=qzHdaFtAZsmIKFhY0c0+/fflDT8Ra+oMMeK1SKLFPpA=; b=eEvqVDAPqxhEwltDxypqsxFQS6VGnUApDqTJXGtE9W9pdsWFA1JFmuZo/Du6DTsp7A 2wZPJ1rdQ+rWFMD6dGANLs5qQtPRoA+qNq533V7Pocm/GVggiOTdyTRf+pG92TWvvOMl LNlMnRZITJCEmmpzqNMQuvtpKTySwQL06HHBXSy80bPJdHwpwG3JARk0XJE0yZiAHlFV 6q7cfQwntJWk0veT8N/ViSXoWNw+H7Lka6MnYSQ5vs8ClOSsBw44zPUjBM7xLa+fYKKg 005JSqmD2I27uls2uCq4Gi6+eLdHVzgSCZGYk3e5zJBbHeABb01DHXdW95KJ9yJiEJhu zbAQ== X-Gm-Message-State: AOJu0YwUoDiaTzI1NVmDFDjjX4hpSqwWnZ1+PqiA74iMI/mhtvRv1iJb fZnhYpi5189NJmfPZeLdRDploCypo7lfy2kSJufgG8LJxr7jbzg46pOPV8KD5e/3AKUx X-Google-Smtp-Source: AGHT+IGH+PhfokLo1kEs2vwiA87FPz14v7bpFm8eVp3DFgecXHiDyAVvw88YAc5NJpJBOHtLVSfuUg== X-Received: by 2002:a17:906:bf47:b0:a2f:7ba2:2fe0 with SMTP id ps7-20020a170906bf4700b00a2f7ba22fe0mr2844425ejb.79.1705965046434; Mon, 22 Jan 2024 15:10:46 -0800 (PST) Original-Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com. [209.85.128.46]) by smtp.gmail.com with ESMTPSA id ks19-20020a170906f85300b00a2b086c29e1sm13799990ejb.127.2024.01.22.15.10.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jan 2024 15:10:46 -0800 (PST) Original-Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-40eb2f3935eso4459255e9.2 for ; Mon, 22 Jan 2024 15:10:46 -0800 (PST) X-Received: by 2002:a7b:c8c9:0:b0:40e:4683:9d69 with SMTP id f9-20020a7bc8c9000000b0040e46839d69mr2700953wml.132.1705965045909; Mon, 22 Jan 2024 15:10:45 -0800 (PST) X-Gmail-Original-Message-ID: Received-SPF: pass client-ip=209.85.218.52; envelope-from=troy.s.brown@gmail.com; helo=mail-ej1-f52.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action 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:278717 Archived-At: I've noticed that "defun" related treesit commands do not appear to work correctly when nested functions are involved. I've seen this behavior in multiple languages and believe the problem is an issue in the treesit.el library. According to the Emacs manual section "Moving by Defuns", the beginning/end-of-defun commands should "... find the beginning and end of the innermost defun around point". I don't see this behavior with the corresponding treesit-beginning-of-defun and treesit-end-of-defun commands. The following example uses python-ts-mode to demonstrate the issue. --8<---------------cut here---------------start------------->8--- # -*- mode: python-ts -*- def outerFunction(text): text = text def innerFunction(text): print(text) innerFunction() def innerFunction2(text): print(text) innerFunction2() --8<---------------cut here---------------end--------------->8--- To reproduce the issue, place point on line 9 (i.e., the call to "innerFunction"). When point is at this location, I've noticed incorrect behavior for the following commands: M-x treesit-beginning-of-defun RET Moves point to the beginning of the "innerFunction" function (line 6) instead of the beginning of the "outerFunction" function (line 3). M-x treesit-end-of-defun RET Moves point to the end of "innerFunction2" function (line 13) instead of the end of the "outerFunction" function (line 15). For comparison, the buffer can be switched to python-mode and the above repeated with the non-treesit versions of these commands to demonstrate that the regular python-mode does work as expected.