Subject: bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return statements

From: Eli Zaretskii <[email-masked]>
Date: Mon, 20 Feb 2023 14:55:53 +0200

> From: Evgeni Kolev <[email-masked]>
> Date: Mon, 20 Feb 2023 10:54:06 +0200
> Cc: [email-masked], Randy Taylor <[email-masked]>, 
> 	Theodor Thornhill <[email-masked]>
> 
> Thank you João for the input! I think something like this would make
> sense in go-ts-mode.el:
> ```
> (with-eval-after-load 'yasnippet
>   (yas-define-snippets 'go-ts-mode
>                        '(("return" (yas-expand-snippet
>                                     (go-ts-mode-return)))
>                          ("iferr" (yas-expand-snippet
>                                    (format "if err != nil {\n%s\n}"
>                                            (go-ts-mode-return)))))))
> ```
> 
> A custom variable go-ts-mode-want-yasnippet could be added to
> optionally prevent adding the snippets.
> 
> Eli, would you consider something like the code above acceptable as an
> alternative to an electric "return" mode?
> 
> Having optional yasnippet integration was also brought up by Theo in
> this message[1] and this one [2].
> 
> [1]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60805#11
> [2]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60805#17

IMO, if we are going to support yasnippet, we should do it in more
than just one mode.  So a short addition to just the go-ts-mode will
not do, and if we want to include stuff like that, it should be part
of a larger patch for Emacs 30.  Whether this is a good alternative
for some electricity is also a good topic for discussion: electric is
part of Emacs whereas yasnippet isn't, so there are advantages and
disadvantages to this proposal.

Thanks.