From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Randy Taylor Newsgroups: gmane.emacs.bugs Subject: bug#60025: [PATCH] Add go-ts-mode and go-mod-ts-mode Date: Wed, 14 Dec 2022 21:56:17 +0000 Message-ID: <4Lmj7Bzx_F4C3v5tPsDR71_8aGGtkra5bbe3LAaEOeFId-atND-VDDi0mKRWOFh2gCC4Y902Y2o9oFf5vExl0PIE5IdCaPp2CJqhoUQ0km8=@rjt.dev> References: <83r0x3pk28.fsf@gnu.org> <83edt2nqgm.fsf@gnu.org> <5HEX4A0JH8fd_VGG1FbzJ8QtBZXlHLKtuAGgc_TUHvzKCzU2Q3PYbbi3rUWeLOBoJzg0qsQgVhwGZCF86A2Xg--I2ep5d1KjKoUoHrxXpqA=@rjt.dev> <87zgbpznfa.fsf@thornhill.no> Mime-Version: 1.0 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="15058"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu , Eli Zaretskii , 60025@debbugs.gnu.org To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 14 22:57:12 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1p5ZkV-0003ii-Fw for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 14 Dec 2022 22:57:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5ZkO-0004NZ-ER; Wed, 14 Dec 2022 16:57:04 -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 1p5ZkM-0004My-Sf for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2022 16:57:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5ZkM-0007Fa-Kn for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2022 16:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p5ZkM-0007IR-8E for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2022 16:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Randy Taylor Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 14 Dec 2022 21:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60025 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 60025-submit@debbugs.gnu.org id=B60025.167105500028027 (code B ref 60025); Wed, 14 Dec 2022 21:57:02 +0000 Original-Received: (at 60025) by debbugs.gnu.org; 14 Dec 2022 21:56:40 +0000 Original-Received: from localhost ([127.0.0.1]:41922 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5Zjz-0007Hz-RQ for submit@debbugs.gnu.org; Wed, 14 Dec 2022 16:56:40 -0500 Original-Received: from mail-4323.proton.ch ([185.70.43.23]:45003) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5Zjw-0007Ht-Ac for 60025@debbugs.gnu.org; Wed, 14 Dec 2022 16:56:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rjt.dev; s=protonmail2; t=1671054990; x=1671314190; bh=a3/BKV9hyUybfZwrYhcPcrG4APTlnlXya3sI5WEfk3Q=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=wFeB4fyUpNKPjfu1ArKyLudaZ7aLcP240/ILujNRd2QEabg+6UnM5bTxt2VgY8HZ4 SlkvoyTQP32dStITylvfD5gcCGFT0hp+ZF35uIcdJme/xtjEeegh7ffVo51bETO/KH YioIoTHh01H3U8kTuNBUnDNKcFuA4SqJ4yoY9SJ0W9uQozvBhdkaA5Kkk25SKUI18c OQIvGoqxJ7L0eEcNEg3IHrbLVLBpAhBf1AMnN/dghomi5gLXsOBm/gVJjSzvg/ClY4 2O3m+Lz9eKPIyxaMUsCw35RH8OWBN7q6Mde6jrcjoD36O/lyRmGiZA2p9LkT2X4pQt dFTkwLvoBPbfw== In-Reply-To: <87zgbpznfa.fsf@thornhill.no> Feedback-ID: 44397038:user:proton X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:251003 Archived-At: On Wednesday, December 14th, 2022 at 16:27, Theodor Thornhill wrote: >=20 > Randy Taylor dev@rjt.dev writes: >=20 > > On Wednesday, December 14th, 2022 at 14:55, Yuan Fu casouri@gmail.com w= rote: > >=20 > > > > I am having a tiny bit of trouble with a go.mod indentation rule. U= sing the patch, create a go.mod file anywhere, activate go-mod-ts-mode and = add the following: > > > >=20 > > > > require () > > > >=20 > > > > Place point inside the parens, and then hit enter. The expectation = is that point will end up indented inside that block. If you add the text "= test v1.0.0" and hit TAB, it will indent properly (and if you hit enter aft= er that text it will indent properly for the next entry). If you go to the = end of the line for the top paren and hit enter, it will not indent (and we= want it to). It seems to give us no-node in that circumstance. Is there a = simple indent rule that can match exactly that that I'm missing? > > >=20 > > > I think you can just test for the parent? In C, if point is at an emp= ty line after a statement in a block, like this: > > >=20 > > > int main() { > > > return 0; > > > | > > > } > > >=20 > > > The matched rule is (parent-is =E2=80=9Ccompond_statement=E2=80=9D), = where compound_statement is the block. In your case, I guess you can test i= f parent is the argument list. > > >=20 > > > Yuan > >=20 > > I do match for the parent, but it doesn't seem to help. > > Here's what tree-sitter explorer shows for the following: > > require ( > >=20 > > ) > >=20 > > (require_directive require ( \n ) \n) > >=20 > > If I put point on the line right below r and do C-S-a, tree-sitter expl= orer shows: > > (require_directive require (*\n ) \n) > > The * indicates that part is highlighted. > >=20 > > The second I make it "proper" like so: > > require ( > > test v1 > > ) > >=20 > > I can hit TAB and it will indent properly (but not anything above it, o= nly that line and anything below). > >=20 > > I would think that checking parent-is for require_directive would be en= ough but it's not somehow??? > > It's instead matching my no-node rule... >=20 >=20 > Yeah, I seem to remember seeing these \n nodes in the go-mode I made > some time ago. There is no node there, so no-node is the rule that > matches, as there is no parent. I believe you can solve it with > something like >=20 >=20 > (defun go-backward-up-list () > (lambda (node parent bol &rest _) > (save-excursion > (backward-up-list 1 nil t) > (back-to-indentation) > (point)))) >=20 > and use some variant of that. Now you can find a different node without > relying on there being a node where you start. >=20 > But I don't remember exactly. Thanks, I'll give that a try. >=20 > BTW, I tried applying this mode, but it wouldn't apply. Applying the patch? It applies to emacs-29 fine for me, and both modes work= as expected when I try them. What issue(s) are you seeing specifically?