Subject: bug#74461: [PATCH] Add go-work-ts-mode

From: Eli Zaretskii <[email-masked]>
Date: Thu, 21 Nov 2024 18:02:50 +0200

> Date: Thu, 21 Nov 2024 07:49:35 -0300
> From:  Gabriel Santos via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> I wrote a tree-sitter mode after founding there wasn't one for Go
> Workspace files. I'd like to say thanks to Randy Taylor on his work to
> the Go tree-sitter mode, helped me a lot in this process.
> 
> Commit message:
> 
> * admin/notes/tree-sitter/build-module/batch.sh:
> * admin/notes/tree-sitter/build-module/build.sh: Add go-work support.
> * etc/NEWS: Mention go-work-ts-mode.
> * lisp/progmodes/eglot.el (eglot-server-programs): Add go-work-ts-mode.
> * lisp/progmodes/go-ts-mode: Add go-work-ts-mode for working with
> workspace files.
> 
> The parser can be found here:
> https://github.com/omertuc/tree-sitter-go-work

I think the parser URL should be mentioned in the comments in
go-ts-mode.el.

> I will mail my copyright assignment to the FSF still today.

Thanks.

> +---
> +** New major mode 'go-work-ts-mode'.
> +A major mode based on the tree-sitter library for editing "go.work"
> +files.  It is auto-enabled for files which are named "go.work".

The last sentence is factually inaccurate: the user needs to load
go-ts-mode to have this mode auto-enabled, right?

> +(defun go-work-ts-mode--in-directive-p ()
> +  "Return non-nil if point is inside a directive.

"inside a go-work directive", I presume?  IOW, the doc string's first
sentence sounds too general.

> +(if (treesit-ready-p 'gowork)
> +    (add-to-list 'auto-mode-alist '("/go\\.work\\'" . go-work-ts-mode)))

Wouldn't it be better to have this in the default value of
auto-mode-alist, just conditioned by (treesit-ready-p 'gowork) ?  That
way, loading go-ts-mode will not change auto-mode-alist.

Stefan, WDYT?