GNU bug report logs -
#61368
[PATCH] Extend go-ts-mode with support for pre-filling return statements
Previous Next
Full log
Message #17 received at 61368 <at> debbugs.gnu.org (full text, mbox):
> From: Evgeni Kolev <evgenysw <at> gmail.com>
> Date: Thu, 9 Feb 2023 13:47:01 +0200
> Cc: 61368 <at> debbugs.gnu.org, dev <at> rjt.dev, theo <at> 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.
This bug report was last modified 1 year and 155 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.