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: Code navigation for sh-mode with Tree-sitter Date: Tue, 6 Dec 2022 16:41:01 -0800 Message-ID: <874E6E80-F72F-4AD2-B3BD-B9850F8ABC51@gmail.com> References: <1B9F9B3A-A757-4A65-9653-CD0112EB8895@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="27240"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , =?utf-8?Q?Jo=C3=A3o_Paulo_Labegalini_de_Carvalho?= , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 07 01:41:45 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 1p2iVM-0006u9-BP for ged-emacs-devel@m.gmane-mx.org; Wed, 07 Dec 2022 01:41:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2iUo-0008MG-QQ; Tue, 06 Dec 2022 19:41:11 -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 1p2iUl-0008Lm-UG for emacs-devel@gnu.org; Tue, 06 Dec 2022 19:41:07 -0500 Original-Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2iUj-0002Oe-Pv for emacs-devel@gnu.org; Tue, 06 Dec 2022 19:41:07 -0500 Original-Received: by mail-pf1-x434.google.com with SMTP id 124so16157723pfy.0 for ; Tue, 06 Dec 2022 16:41:05 -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=1w/cG2hECp3MKMRXmm2Gw466eSnqYWirzOc9aFwATOY=; b=iGaXtkQFOiFX4GH8KK2rz4M4MwkEe2AtBqPcvSvY7Uib3xwkvJGFmgwExg4HlXkr0A xMlaU3MshFgVKnVwyI/9ykRgpOrOEKI95FMmeXd2lk/yui46AeQ4jLQRbCqLRqG/ThAh 63IZGZ3wXKEdVtlFtOSiRtLoWqQ4xisSPnVzPLNCZJacH1kMVpaPyX8lwb1TQYHlj/aY gJ36nwLY+t3ODfh67nMSunHB2CZGnG/P4jtbWXtt33SqMjUtksYmE5Xfi9Xx1BMb0Yew h8dqA2MvnwUJkncjrTbbIDACKVgY4KxQs+pTdScUkiQECgSyKdgGLo6Q2/aajRH96n5z CDMg== 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=1w/cG2hECp3MKMRXmm2Gw466eSnqYWirzOc9aFwATOY=; b=lgC8R1Z1su0uLoWzAh0ud573PhLO9QODjCueD06rd+sm0mO0VQdccVsiZ8D4EAT1Dt xPQ3dMwCcur+Wa4DDxScmm3oH0OMnHWo5WJWGOVBiHMwpNq4GaCG7ArI7sspmYnlF8U+ /dLSeY9MXpGt5MkKowov4xEW4Zgt2ihLBnfE+hlupR978JPDM+N0W5sseR45HUqewMjI StETJhrQL2vYl1bByRJYnJgQS/mVaRxlXp0h4pV+zbo8gZvhRgp1p0r3oeDYs5Fh3lef /6Af0DXvXwYIIDkYz8idVJhApxt8hODoJSylf61qzgTua17V5teSbJnARjXkwBb7bu08 GACQ== X-Gm-Message-State: ANoB5pmh8qHoH5T2+bn1OMPDt/wCdj6UQFAy5hFwVr69YSyeMNd1lb2I RGeUIM+w1my0OL0e7ZxGrXs= X-Google-Smtp-Source: AA0mqf5zOXmAnl6EFnvW31NSRhk9vu4TeLS6Asxb9ecG+sZH37XCkkh9ryIJ4hibqjSYHb/+JSQ2Mg== X-Received: by 2002:a63:fe16:0:b0:46b:8e9:7d5f with SMTP id p22-20020a63fe16000000b0046b08e97d5fmr64463473pgh.597.1670373664186; Tue, 06 Dec 2022 16:41:04 -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 z28-20020aa7991c000000b005772f762e43sm2479880pff.13.2022.12.06.16.41.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2022 16:41:03 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=casouri@gmail.com; helo=mail-pf1-x434.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:300995 Archived-At: >=20 >>> Should we make it configurable, then? A variable that makes >>> tree-sitter defun navigation switch between two modes: top-level = only >>> and not top-level only.=20 >=20 > In CC Mode, it has been configurable via the user option = c-defun-tactic > for somewhere between ten and fifteen years. When c-defun-tactic is = t, > C-M-a/e go to the start/end of the top level defuns. When it is the > symbol go-outward, C-M-a/e move to the next start/end of defun, if = any, > at the current level of class/namespace nesting, and move outwards to > the next level of class/namespace nesting when a class/namespace = boundary > is reached. >=20 > I don't remember any complaints about this mechanism. Ah, very good. I=E2=80=99ll try to make tree-sitter to do the same. >=20 >> And for functions nested in a class: if you type C-M-e at the = beginning >> of a class, should it go to the end of the first function in that >> class, or should it go to the end of the class? Right now because of >> how end-of-defun works, it will jump to the end of the class if point >> is at the beginning of the class (1), and jump to the first function = if >> point is before the beginning of the class (2). >=20 > This doesn't seem sensible. I agree. >> (2) >> (1)class class1(): >> prop =3D 0 >> def method1(self): >> pass >=20 >> def method2(self): >> pass How would cc-mode=E2=80=99s C-M-e move in position (2) under the = go-outward tactic? Would it go to the end of method1, or the end of = class1? =46rom your description it seems that it will move to the end of = class1. Is there anyway to configure it to move to the end of method1 in = this case? Yuan=