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 16:43:39 -0700 Message-ID: References: <1B9F9B3A-A757-4A65-9653-CD0112EB8895@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000004deb7b05ef316091" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28898"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Alan Mackenzie , Yuan Fu , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 07 00:44:41 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 1p2hc9-0007HT-EC for ged-emacs-devel@m.gmane-mx.org; Wed, 07 Dec 2022 00:44:41 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2hbS-00031y-1j; Tue, 06 Dec 2022 18:43:58 -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 1p2hbP-00031f-Gq for emacs-devel@gnu.org; Tue, 06 Dec 2022 18:43:55 -0500 Original-Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2hbN-0000el-Sn for emacs-devel@gnu.org; Tue, 06 Dec 2022 18:43:55 -0500 Original-Received: by mail-pj1-x102b.google.com with SMTP id u5so6605322pjy.5 for ; Tue, 06 Dec 2022 15:43:53 -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=Jp4GTEdpqqJZ9QOD4TUagnbKancbWh4NhtWzMye6wq8=; b=TEdv86zgLi7DrbAY3Uj4j/lGRr3iKPy6BkuYabDt7F4iRWTjA24GTU/ZAoOYICPGuY mL+Ds6rEFF17DBefoZJA+MesV87hPVc/KLVB381ZMxk/d4GYX/q6vZLOruCUYpjeD1Lk B/Oh5cEVjkX0LfBzCbIIZy3BM07HMxhwWVbj+eN0go4KeNGM70z43aZtf+qafoL1s3k1 tQjdCCXDnnNYF8aNLa9lQON9DwJzluO3ieAMuy9snWQNrffRjG0L93k7NJ3zstGfGxsF oUtwv04zhJWh/w3CuX462byp8EV9NLU6b0NzDqOlqyCzWmyX8Dm7bbc5Um3WNXCmPb/a UMoQ== 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=Jp4GTEdpqqJZ9QOD4TUagnbKancbWh4NhtWzMye6wq8=; b=WdCLwxjgIhvIhirwIF+qdLRhCxPRRfbFecpusaWUmDYYbFxbSc8Q3mqexmCdMph7Nj pQKeKb5DxxK3MesusM3WlBZO9XxitATbSZnAxb6S9dVo3GGDoWzZhFyR6T5EspZvvyNc p5d9kahx8imUxQM1voEUfus3QiST7RtH5IXmza0REAZl6plfhqyZ/rvDvTui8hHTS4cI cwy0HOWC7IPlZf/rW5Ry+40pLNCvSbow6tH7cu3GfPTejWfXwHmdWmB1YFN7YbbHBJ28 RMUc4cqYO1mS6zyDTZ2Pt4H6rgxa50uraD0Gkp2bPRrXDlXhygAE5NhrLY4F7vwuBnBB H2vQ== X-Gm-Message-State: ANoB5pnaYR2VhyAVVko6xEII2z6jcz7wUOElqz4nVTyVyZLm2b9mYUNp q4oC+SuzYmJlLLioGOMuyxJgkhMjKpXAVEr9xbc= X-Google-Smtp-Source: AA0mqf58IeLj6z48ThOy4acbis2+L7eSMtH9prg45SFaJkqVHgkcjXiL0gjDeXOMfDDR+RCui9aZuo60gXQ6gJSXuRE= X-Received: by 2002:a17:902:be01:b0:186:7db1:d2a4 with SMTP id r1-20020a170902be0100b001867db1d2a4mr75448102pls.84.1670370231706; Tue, 06 Dec 2022 15:43:51 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=jaopaulolc@gmail.com; helo=mail-pj1-x102b.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:300992 Archived-At: --0000000000004deb7b05ef316091 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Dec 6, 2022 at 3:57 PM Stefan Monnier wrote: > Ah, I think I get it. You mean your set the `[EB]OD-function` variables > to your two functions/commands, right? > Exactly. > To figure out whether the problem is inside `end-of-defun` or in the > way `[EB]OD-function` are expected to behave, you'll have to single-step > through `end-of-defun`, I think. > It seems that the problem originates from the function which `EOD-function' is set to be called after via the `BOD-raw'. With a positive argument all is good, since the navigation functions for bash-ts-mode have symmetric behavior -- both bring point to beginning/end of the closest function that encloses point. However, with negative arguments that does not happen, as `sh-mode--treesit-beginning-of-defun' moves point to (beginning of) the closest sibling function (after point) and `sh-mode--treesit-end-of-defun' moves point to (end of) the closest sibling function (before point). In this case, the selected functions to which point move to are not the same. A second look revealed that the function set to `end-of-defun-function' is called without arguments, thus when used can only produce motions that are symmetric to `beginning-of-defun-function'. Since that is not the case for the functions I am proposing for bash-ts-mode, I believe that binding them as commands to C-M-a/e is the only option. Unless I am missing something. --=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 --0000000000004deb7b05ef316091 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Dec 6, 2022 at 3:57 PM Stefan= Monnier <= monnier@iro.umontreal.ca> wrote:
Ah, I think I get it.=C2=A0 You mean your set the `= [EB]OD-function` variables
to your two functions/commands, right?

= Exactly.=C2=A0
=C2=A0
To figure out whether the problem is inside `end-of-defun` or in the
way `[EB]OD-function` are expected to behave, you'll have to single-ste= p
through `end-of-defun`, I think.

It seems that the= problem originates from the function which `EOD-f= unction' is set to be called after via the `BOD-raw'. With a positive argument all is good, since the n= avigation functions for bash-ts-mode have s= ymmetric behavior -- both bring point to beginning/end of the closest funct= ion that encloses point.

However, with negative ar= guments that does not happen, as `sh-mode--treesit= -beginning-of-defun' moves point to (beginning of) the closest s= ibling function (after point) and `sh-mode--treesi= t-end-of-defun'=C2=A0moves point to (end of) the closest sibling= function (before point). In this case, the selected functions to which poi= nt move to are not the same.

A second look revealed that the functio= n set to `end-of-defun-function' is cal= led without arguments, thus when used can only produce motions that are sym= metric to `beginning-of-defun-function'= .

Since that is not the case for the functions I am proposing for ba= sh-ts-mode, I believe that binding them as commands to C-M-a/e is the only = option. Unless I am missing something.

--
Jo=C3=A3o Paulo L. d= e Carvalho
Ph.D Computer Science | =C2=A0IC-UNICAMP | Campinas , SP - Br= azil
Postdoctoral Research Fellow | University of Alberta | Edmonton, AB= - Canada
--0000000000004deb7b05ef316091--