unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Randy Taylor <dev@rjt.dev>
To: Theodor Thornhill <theo@thornhill.no>
Cc: Yuan Fu <casouri@gmail.com>, Eli Zaretskii <eliz@gnu.org>,
	60025@debbugs.gnu.org
Subject: bug#60025: [PATCH] Add go-ts-mode and go-mod-ts-mode
Date: Wed, 14 Dec 2022 21:56:17 +0000	[thread overview]
Message-ID: <4Lmj7Bzx_F4C3v5tPsDR71_8aGGtkra5bbe3LAaEOeFId-atND-VDDi0mKRWOFh2gCC4Y902Y2o9oFf5vExl0PIE5IdCaPp2CJqhoUQ0km8=@rjt.dev> (raw)
In-Reply-To: <87zgbpznfa.fsf@thornhill.no>

On Wednesday, December 14th, 2022 at 16:27, Theodor Thornhill <theo@thornhill.no> wrote:
> 
> Randy Taylor dev@rjt.dev writes:
> 
> > On Wednesday, December 14th, 2022 at 14:55, Yuan Fu casouri@gmail.com wrote:
> > 
> > > > I am having a tiny bit of trouble with a go.mod indentation rule. Using the patch, create a go.mod file anywhere, activate go-mod-ts-mode and add the following:
> > > > 
> > > > require ()
> > > > 
> > > > 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 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 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?
> > > 
> > > 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:
> > > 
> > > int main() {
> > > return 0;
> > > |
> > > }
> > > 
> > > The matched rule is (parent-is “compond_statement”), where compound_statement is the block. In your case, I guess you can test if parent is the argument list.
> > > 
> > > 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 explorer 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, only that line and anything below).
> > 
> > I would think that checking parent-is for require_directive would be enough 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.

Thanks, I'll give that a try.

> 
> 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?





  reply	other threads:[~2022-12-14 21:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13  2:13 bug#60025: [PATCH] Add go-ts-mode and go-mod-ts-mode Randy Taylor
2022-12-13 12:25 ` Eli Zaretskii
2022-12-13 19:39   ` Randy Taylor
2022-12-14 12:02     ` Eli Zaretskii
2022-12-14 16:21       ` Randy Taylor
2022-12-14 19:55         ` Yuan Fu
2022-12-14 20:54           ` Randy Taylor
2022-12-14 21:27             ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-14 21:56               ` Randy Taylor [this message]
2022-12-15  2:15               ` Randy Taylor
2022-12-15  7:20                 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-15 16:40                   ` Randy Taylor
2022-12-15 18:06                     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-15 19:45                       ` Randy Taylor
2022-12-15 19:59                         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-15 20:09                           ` Randy Taylor
2022-12-15 22:22                             ` Randy Taylor
2022-12-14  2:22 ` Yuan Fu
2022-12-16  1:22 ` Yuan Fu
2022-12-16  2:05   ` Randy Taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='4Lmj7Bzx_F4C3v5tPsDR71_8aGGtkra5bbe3LAaEOeFId-atND-VDDi0mKRWOFh2gCC4Y902Y2o9oFf5vExl0PIE5IdCaPp2CJqhoUQ0km8=@rjt.dev' \
    --to=dev@rjt.dev \
    --cc=60025@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).