From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#60025: [PATCH] Add go-ts-mode and go-mod-ts-mode Date: Wed, 14 Dec 2022 22:27:05 +0100 Message-ID: <87zgbpznfa.fsf@thornhill.no> References: <83r0x3pk28.fsf@gnu.org> <83edt2nqgm.fsf@gnu.org> <5HEX4A0JH8fd_VGG1FbzJ8QtBZXlHLKtuAGgc_TUHvzKCzU2Q3PYbbi3rUWeLOBoJzg0qsQgVhwGZCF86A2Xg--I2ep5d1KjKoUoHrxXpqA=@rjt.dev> Reply-To: Theodor Thornhill 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="35815"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 60025@debbugs.gnu.org To: Randy Taylor , Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 14 22:28:13 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 1p5ZIT-000974-9G for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 14 Dec 2022 22:28:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5ZIK-0002Js-VR; Wed, 14 Dec 2022 16:28: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 1p5ZIJ-0002Jj-B9 for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2022 16:28:03 -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 1p5ZIJ-0001Sc-2C for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2022 16:28:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p5ZII-0006ws-Ao for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2022 16:28:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 14 Dec 2022 21:28: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.167105323926701 (code B ref 60025); Wed, 14 Dec 2022 21:28:02 +0000 Original-Received: (at 60025) by debbugs.gnu.org; 14 Dec 2022 21:27:19 +0000 Original-Received: from localhost ([127.0.0.1]:41882 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5ZHX-0006wZ-WD for submit@debbugs.gnu.org; Wed, 14 Dec 2022 16:27:19 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]:40895) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5ZHR-0006wR-UT for 60025@debbugs.gnu.org; Wed, 14 Dec 2022 16:27:14 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1671053228; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f+3kG1LbBWx/25ryn4J9MRbeIXZB9bxaEAhXBrTzZKA=; b=fYHTzTupNYfktJdybI+DcTaLNd9DBpPQG7+6SDxORDONI4RiYx3QFTlIO2ZOVXSQDRbQBb j936PtY4rScDF2CuvK2pdzFzuGdTEyD+t11mOb+t6vRyoXSjM7wdaRvdjFz8bC8m6UTSct XoCi45UXsj34NVykhKAOm/13WbddGacb59udHWP4R3NUsuxp+Ba4WemlhBYXIs8LOtQ+hQ L0Rng6+vlkJ6dx3TLnEaXt1t4EmVYZa+A+v688YJCWnqL3LXKYNHQ6Q0kBeiOI177Gb56A PtFOJCMUn/bRCE+TrbEGO7JdcAy/bNo+xTpqf8rp3g5gA5z1vC03GOhOBWYgsg== In-Reply-To: X-Migadu-Flow: FLOW_OUT 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:250998 Archived-At: Randy Taylor writes: > On Wednesday, December 14th, 2022 at 14:55, Yuan Fu w= rote: >>=20 >> > I am having a tiny bit of trouble with a go.mod indentation rule. Usin= g 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 "tes= t v1.0.0" and hit TAB, it will indent properly (and if you hit enter after = 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 wa= nt it to). It seems to give us no-node in that circumstance. Is there a sim= ple indent rule that can match exactly that that I'm missing? >>=20 >>=20 >> I think you can just test for the parent? In C, if point is at an empty = 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), whe= re compound_statement is the block. In your case, I guess you can test if p= arent is the argument list. >>=20 >> Yuan > > I do match for the parent, but it doesn't seem to help. > Here's what tree-sitter explorer shows for the following: > require ( > > ) > > (require_directive require ( \n ) \n) > > If I put point on the line right below r and do C-S-a, tree-sitter explor= er shows: > (require_directive require (*\n ) \n) > The * indicates that part is highlighted. > > The second I make it "proper" like so: > require ( > test v1 > ) > > I can hit TAB and it will indent properly (but not anything above it, onl= y that line and anything below). > > I would think that checking parent-is for require_directive would be enou= gh but it's not somehow??? > It's instead matching my no-node rule... 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 (defun go-backward-up-list () (lambda (node parent bol &rest _) (save-excursion (backward-up-list 1 nil t) (back-to-indentation) (point)))) and use some variant of that. Now you can find a different node without relying on there being a node where you start. But I don't remember exactly. BTW, I tried applying this mode, but it wouldn't apply. Theo