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 13:04:19 -0800 Message-ID: <1B9F9B3A-A757-4A65-9653-CD0112EB8895@gmail.com> References: 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="39539"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?utf-8?Q?Jo=C3=A3o_Paulo_Labegalini_de_Carvalho?= , Alan Mackenzie , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 06 22:05:14 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 1p2f7p-000A1J-VL for ged-emacs-devel@m.gmane-mx.org; Tue, 06 Dec 2022 22:05:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2f75-0008Cy-Cv; Tue, 06 Dec 2022 16:04:27 -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 1p2f73-0008Cj-9A for emacs-devel@gnu.org; Tue, 06 Dec 2022 16:04:25 -0500 Original-Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2f71-00066P-O8 for emacs-devel@gnu.org; Tue, 06 Dec 2022 16:04:25 -0500 Original-Received: by mail-pg1-x530.google.com with SMTP id h33so14454497pgm.9 for ; Tue, 06 Dec 2022 13:04:23 -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=78Ff3Ng+PIklmY8BQUgacC1YLDDoS3kDIh1K20U13Gc=; b=qplmZJOUzPonM/ZBJAtuHVAkSeGfJIiEjWIaylS37iBNod4Xv9dLNQyWuT0TRHoAG7 UnQNTDYi9ZdoDWHAzKvUJ2yo/vJXX2TPcRKcJ1XNB+JQ1DvpR/zuixdghG8i6o4hjFem 7xpxCY8y8BTlwRjBWt35fbMokjJej1a0FRPPDCfcosTCOUDQZlG3SPKLvs3UodpEty1+ qiW0HZDE4edFCUhYIckrfQOUjWfFHQHH8hhft04qy39rjc2xKgVLklnQ2EAL8do6QjYH sN1kpJaAgJNagLDY1RxNJDBOpzUPuaC3G/DfTiwokVzjNi9E5a+Yd+hVwQVPORREmONu rRlw== 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=78Ff3Ng+PIklmY8BQUgacC1YLDDoS3kDIh1K20U13Gc=; b=Lv6c7B4gHJBLyDJIXDHv0Bs4o7o9obn9BqI3v11Sco718a5nCIBEtekYOBgjWpMO6e gBwm4vCc2RhrQaq7ZSkqiEV8WQ1UTDWkVmeBj4nbrMmFF9ebJP0j8ZpJ5uKPBJ/bVZIa UZzP3JGss3DW+e8w4wCO1N3FiyjLz7GViWyx3CCKK/FvCaATnRc3FaqieTR6loAbiaOg UngMkRDRrSDeNKbQHPwdcr5Ewn/ELxfOmVK7FRWIM9OKrYoQHdKJNTY/shxxQknFFt3e RVTSQvouMIy548JVgtk68p3bq1gyBV7vH/JvtEx271pIzExQeAhvYKGDMBit2np5meIg okLw== X-Gm-Message-State: ANoB5pmp5ZgTocYyfzCNy+P8plQrNxVp5Hp+rh/s0crIqsksBSvJeaXp rTtVsj2I3cBiSzyFJauB7PzSJyIzQ7UKEw== X-Google-Smtp-Source: AA0mqf46xOXLI5ThXsbgerwh91xwNWsOaRqdDwyW8e3l1pjU0ZKhYVJCua5nI9yEeH8KjPP0KQq/8g== X-Received: by 2002:a63:1062:0:b0:470:a47:996a with SMTP id 34-20020a631062000000b004700a47996amr62635662pgq.377.1670360661570; Tue, 06 Dec 2022 13:04:21 -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 z20-20020aa79f94000000b0056be4dbd4besm12130372pfr.111.2022.12.06.13.04.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2022 13:04:21 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=casouri@gmail.com; helo=mail-pg1-x530.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:300982 Archived-At: > On Dec 6, 2022, at 8:48 AM, Stefan Monnier = wrote: >=20 >>> Calling beginning-of-defun-function followed by = end-of-defun-function >>> (and comparing the resulting position to the start position) should = be >>> sufficient to let you know whether or not you're inside the function >>> whose definition starts most closely before point. >>>=20 >>=20 >> Hmm. In sh-mode `beginning-of-defun-function' is nil and in the = example >> below, calling `end-of-defun-function' with M-: (funcall >> end-of-defun-function) brings point to fi and not the end of the = function. >=20 > Many major modes do not implement those two functions in a fully > reliable way, indeed. >=20 > `bash-ts-mode` should be able to implement them reliably, OTOH. >=20 >> In the example above, C-M-a and C-M-e do the right thing. However, in = the >> presence of nested functions, C-M-a and C-M-e only navigate over = top-level >> functions. For example: >=20 > Yes, it's a common limitation when the major mode is unable to do > proper parsing of the code. It seems there are not convention on whether defun movements should move = across top-level defun=E2=80=99s or both top-level and nested ones. = I=E2=80=99ve seen bug report on python-ts-mode complaining about both = sides. 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 Yuan=