[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return
From: |
Eli Zaretskii |
Subject: |
bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return statements |
Date: |
Thu, 09 Feb 2023 15:39:55 +0200 |
> From: Evgeni Kolev <evgenysw@gmail.com>
> Date: Thu, 9 Feb 2023 13:47:01 +0200
> Cc: 61368@debbugs.gnu.org, dev@rjt.dev, theo@thornhill.no
>
> > Instead of a command bound to a special key sequences, would it
> > perhaps make more sense to add some kind of "electric" behavior to
> > "normal" keys? Like perhaps typing RET after inserting "return" would
> > add the "context-aware return statement"? Then the user could turn on
> > the electric behavior with some minor mode, and get this behavior,
> > while avoiding the need to dedicate a key sequence.
> >
> > WDYT?
>
> Makes sense. I am familiar with electric-pair-mode. I see that it adds
> a hook in post-self-insert-hook. Is your suggestion to do something
> like this:
> - add hook in post-self-insert-hook
> - in the hook check if RET is typed after an "return"
> - if yes, replace the "return" with the "context-aware return
> statement", possibly using (yas-expand-snippet)
Yes, something like that. See electric.el for more examples.
> I'm wondering what customization options would make sense for users -
> changing the electric trigger from "return" RET to "ret" RET for
> example.
>
> Is there another major mode which can be used as an example for such
> electric behavior?
Electric modes are usually minor modes that let major modes customize
them by setting variables. Again, I think you will find examples in
electric.el.
- bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return statements, Evgeni Kolev, 2023/02/08
- bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return statements, Eli Zaretskii, 2023/02/08
- bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return statements, Evgeni Kolev, 2023/02/09
- bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return statements,
Eli Zaretskii <=
- bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return statements, Evgeni Kolev, 2023/02/18
- bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return statements, João Távora, 2023/02/18
- bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return statements, Evgeni Kolev, 2023/02/20
- bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return statements, Eli Zaretskii, 2023/02/20
- bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return statements, Evgeni Kolev, 2023/02/22
bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return statements, Theodor Thornhill, 2023/02/08