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

From: João Távora <[email-masked]>
Date: Sat, 18 Feb 2023 12:14:49 +0000

On Sat, Feb 18, 2023, 11:46 Evgeni Kolev <[email-masked]> wrote:

> + João, author of yasnippet.
>
> Hi, João, I'd appreciate any suggestions you might have. I'm aiming to
> extend go-ts-mode with a snippet-like feature. go-ts-mode would be
> able to insert a "smart / context-aware" return statement. My question
> is - is there a way for major modes to provide yasnippet snippets? My
> understanding is the snippets are either created by each user
> individually, or distributed as a collection of snippets (e.g.
> yasnippet-snippets).

Snippets can be distributed as files, but that's not a very good way as I
see it today. One of the  reasons might be too leverage the TAB and menu
expansion of the yasnippet system. But probably you don't want this, and
snippets can also be defined programmatically, albeit not with a beautiful
language.

Are there any major modes which provide snippets
> (I wasn't able to find any in emacs' repo)?
>

That's because yasnippet is not part of the Emacs repo proper, i.e. the
"core". So adding snippets to major modes in the core would introduce into
the core a dependency on an non-core ELPA package.

Nevertheless, there are ways to conditionally provide functionality based
on whether the non-core package is detected.  A soft dependency. In my
opinion it makes sense for popular non-core packages: company,
markdown-mode, yasnippet, etc. Look at Eglot, for example.

João

João