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.devel Subject: Re: New defun navigation for tree-sitter (Was: Code navigation for sh-mode with Tree-sitter) Date: Tue, 13 Dec 2022 10:07:54 -0800 Message-ID: <0B190C0C-24BE-490C-9C7D-1439B77EE9D5@gmail.com> References: <1B9F9B3A-A757-4A65-9653-CD0112EB8895@gmail.com> <5BB6E79A-B1FA-40F4-B48A-DADF63A30DDC@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.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="23347"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , Alan Mackenzie , emacs-devel@gnu.org To: =?utf-8?Q?Jo=C3=A3o_Paulo_Labegalini_de_Carvalho?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 13 19:08:35 2022 Return-path: Envelope-to: ged-emacs-devel@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 1p59hj-0005w4-3g for ged-emacs-devel@m.gmane-mx.org; Tue, 13 Dec 2022 19:08:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p59hD-0001JW-JM; Tue, 13 Dec 2022 13:08:03 -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 1p59hB-0001J6-M4 for emacs-devel@gnu.org; Tue, 13 Dec 2022 13:08:01 -0500 Original-Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p59hA-0003XT-1r for emacs-devel@gnu.org; Tue, 13 Dec 2022 13:08:01 -0500 Original-Received: by mail-pl1-x62c.google.com with SMTP id m4so644557pls.4 for ; Tue, 13 Dec 2022 10:07:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=fBmtVSBajtEB6VPd1mEKPrsCO3kiiIFawMhRmJT34mI=; b=ZAz1wQeGYii9YHUex1UdhN/KdqubQmC6voSgPEUy2GKLCFdZ9ZS59Ii2cteLturZFg t9aDtKPVCaFoHZjUy/ozstTQyF8P2N3wrx3octfKf25twg61ZlrN+Q3Y7nRyD5A+5v3a G32Xu6y9NGRojmLAx8lJYPmu0BTp3aDKbzegGv/7/RBzoPPIJAMhGmWu1ePh0qdWK5H3 OQxp0sGix9AlMsrCuOnFWeF+2uwbLXytfH37W4hkoGIiLmj7gBXFAeKzyqQ9red5bjgQ ylka8ngoz0Uu+y3js36fEyAXVGy7pc8/qQx7EVBNyj2gm8AvzSLgCRhto8GneoYcjfA2 1bEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=fBmtVSBajtEB6VPd1mEKPrsCO3kiiIFawMhRmJT34mI=; b=fNwqaQSw7YUd44498psY6pZEmAoold4QmVPxGEjiYKPaJOyx1+X9dABqW52mHXpVjI GgzN9W9Y4QpQZspMtH0E/pVLqxcCCvFtolk2cvDc/1tZr3vxFbE461HlAMFuBiHkGODO lq9D+Y7tAnfaVkF3CpXskJhPGSZA3KsoM8BedrnFi3+kkACn8au9l09v61E3VAjMTfIa 6oLKV6rZCPGcvlyzsvaK+c/WolF38n6Jx9Zld+SHTLnRGScPYWPZMeIp4rj1HUG663FX 1UqEx9DDQCTyrTrmjJlY9Uai24fLGCsHBeOLAiufh9wRTO2rmpj/ZtbyLH2C0nKwzRek 8v/Q== X-Gm-Message-State: ANoB5pmdwWAIEZCSATUTU78oSAxlzkOmOkc58xkCw+rMZLQiGTL+rseB QkIoGexfddPhUwLOBcd5Lvc= X-Google-Smtp-Source: AA0mqf5Qe9y9k/+n3sPyp7TnuKyH8vhMw5pgjnx9v8bPAqpfVV2wJY6W+7CaM6n/X3NxLzn50LWeDA== X-Received: by 2002:a17:903:1109:b0:185:441f:70a1 with SMTP id n9-20020a170903110900b00185441f70a1mr29109275plh.38.1670954878033; Tue, 13 Dec 2022 10:07:58 -0800 (PST) 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 e8-20020a170902784800b00186c3afb49esm170148pln.209.2022.12.13.10.07.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Dec 2022 10:07:57 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=casouri@gmail.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:301338 Archived-At: > On Dec 13, 2022, at 8:11 AM, Jo=C3=A3o Paulo Labegalini de Carvalho = wrote: >=20 > Great job, Yuan. >=20 > The new `treesit--navigate-defun' does work as documented. However, = the behavior does feel a little awkward to me. >=20 > For instance, if I am within a function I would expect to go to its = beginning when pressing C-M-a, and not to the beginning of the first = leaf function when searching backward. Although the current behavior = might be desirable to some users and should be possible as well. >=20 > The navigation style that I came up with for bash-ts-mode is to = navigate only to functions in the same level or higher of the tree. That = seems to be the motions I usually rely on when writing/editing code. But = that might just be me. Treesit--navigate-defun should, as you did in bash-ts-mode, only = navigate in the same level (siblings) or higher (parents). Could you = show an example of the unexpected behavior? For a function like the following and point at (1), moving back to = beg-of-defun goes to (2), then (3), and never goes to (X). (3)def method(): (2)def method1(): (X)def method11(): return 0 return 0 (1)def method2(): def method22(): return 0 return 0 Yuan=