From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_Paulo_Labegalini_de_Carvalho?= Newsgroups: gmane.emacs.devel Subject: Re: Code navigation for sh-mode with Tree-sitter Date: Tue, 6 Dec 2022 14:46:41 -0700 Message-ID: References: <1B9F9B3A-A757-4A65-9653-CD0112EB8895@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000f8a2b805ef2fbd0d" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12949"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu , Stefan Monnier , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 06 22:48:08 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 1p2fnM-00039B-3t for ged-emacs-devel@m.gmane-mx.org; Tue, 06 Dec 2022 22:48:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2fmd-0001kR-Ap; Tue, 06 Dec 2022 16:47:23 -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 1p2fmW-0001j5-Ns for emacs-devel@gnu.org; Tue, 06 Dec 2022 16:47:16 -0500 Original-Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2fmO-0005JP-K9 for emacs-devel@gnu.org; Tue, 06 Dec 2022 16:47:16 -0500 Original-Received: by mail-ej1-x62b.google.com with SMTP id vp12so9596356ejc.8 for ; Tue, 06 Dec 2022 13:46:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=O5tx99Lb87ViMhR2l6q6l3ZhjlaRYUJJOqo/jQFlkpU=; b=KXTEO2VpJecR7vC8nkoUdptwPje5FsVB/3fJ9nh8zTlOeX+on3RWS3bl2GicoCwtXx 7wtV1DsQOTjnVGac1LEv1oqKN+TJ9eLxb0Scuoz60uQIZleKL5bmx0AACyv5mKkvrC3U JNrJOg2ToXM/x2KFqvMxHJuusX/IV4gAzob9Qtp+Fg1vcLFRpoUpArMvOUOE58WvgMV4 hfduso5nyYdDjaoG1XGHnsfit/TKgYcuduNnKfjmBxz7hvGyvNCjthdOCljrFhe+NWoG LZL6TvduDNrup365xd6syA5yvllFhfYutgDodkBmdBYKKVFACaHWif0hyTqIvGmrwKDC swGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=O5tx99Lb87ViMhR2l6q6l3ZhjlaRYUJJOqo/jQFlkpU=; b=ZOTNb6mQ6t7KmFi4se1oyq889zyO4G2m8lz0bhl8Pf3T4bsNQclEtpo5XXevkuT/E2 hbnCQqxe7CRJNjX14Nnya8ZrpYOHV0KLZt493qY4IAckHF8LyUg/L46cVZ3opQlNdG0q DP8DI5+rAJcmtiu6tSGGFnaO8NE3k22XvZIqwEXRwpX7C/ArQ3A1KoUeKC0HY4j0kTdz Vg7phD35EdWWHpMIxaAjvXV8ssLCvfm2PHBycMWIriXFXHivu6ZA0B/1sQgS7U/+OdaB UODhfGZz/snHnzaRB4gkZ1JSxt22/Xy7p45bk/hbEnMmPyM3EWXe0n4uziiu++iku8RR BCWg== X-Gm-Message-State: ANoB5pla6Q0WLKXe6PkSxa7y9WSYqQ+JrspzcDmh7S82k/Vhif4ugeij UXB1n7L09MvSdcTO7D/tfBvTDIDL0PgN+1LfIr8= X-Google-Smtp-Source: AA0mqf7iCDOuONcKzp0kKeydLT0dckV47cs5ytomLdf00LWldbf37HIxdyELRMxPOdR2ueefXDY5YvEwNDKBhwBkxdM= X-Received: by 2002:a17:906:6417:b0:7ae:937f:2c38 with SMTP id d23-20020a170906641700b007ae937f2c38mr59480924ejm.201.1670363213241; Tue, 06 Dec 2022 13:46:53 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=jaopaulolc@gmail.com; helo=mail-ej1-x62b.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, HTML_MESSAGE=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:300985 Archived-At: --000000000000f8a2b805ef2fbd0d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > > > 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. > > 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. > The 'go-outward behavior is the one I have implemented. I don't remember any complaints about this mechanism. > > > 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). > > This doesn't seem sensible. > I tend to agree. I would expect it to go to the nearest node (either class or function) and not bypass a class node in favor of function nodes. --=20 Jo=C3=A3o Paulo L. de Carvalho Ph.D Computer Science | IC-UNICAMP | Campinas , SP - Brazil Postdoctoral Research Fellow | University of Alberta | Edmonton, AB - Canad= a joao.carvalho@ic.unicamp.br joao.carvalho@ualberta.ca --000000000000f8a2b805ef2fbd0d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> > Should we make it configurable, then? A variab= le that makes
> > tree-sitter defun navigation switch between two modes: top-level = only
> > and not top-level only.

In CC Mode, it has been configurable via the user option c-defun-tactic
for somewhere between ten and fifteen years.=C2=A0 When c-defun-tactic is t= ,
C-M-a/e go to the start/end of the top level defuns.=C2=A0 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.

The 'go-outward behavio= r is the one I have implemented.

I don't remember any complaints about this mechanism.

> And for functions nested in a class: if you type C-M-e at the beginnin= g
> 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<= br> > is at the beginning of the class (1), and jump to the first function i= f
> point is before the beginning of the class (2).

This doesn't seem sensible.

I tend to agree. I= would expect it to go to the nearest node (either class or function) and n= ot bypass a class node in favor of function nodes.=C2=A0
--
=
Jo=C3=A3o Paulo L. de Carvalho
Ph.D Compute= r Science | =C2=A0IC-UNICAMP | Campinas , SP - Brazil
Postdoctoral Resea= rch Fellow | University of Alberta | Edmonton, AB - Canada
joao.carvalho@ic.unicamp.br
joao.carvalho@ualberta.ca
--000000000000f8a2b805ef2fbd0d--