GNU bug report logs -
#61368
[PATCH] Extend go-ts-mode with support for pre-filling return statements
Previous Next
Full log
Message #8 received at 61368 <at> debbugs.gnu.org (full text, mbox):
> Cc: Randy Taylor <dev <at> rjt.dev>, Theodor Thornhill <theo <at> thornhill.no>
> From: Evgeni Kolev <evgenysw <at> gmail.com>
> Date: Wed, 8 Feb 2023 17:27:58 +0200
>
> This is a patch which adds support to go-ts-mode to insert
> context-aware return statements for the current function. The return
> statements are pre-filled with the Go zero values of the output
> parameters.
>
> For example, all these return statements are inserted by M-x
> go-ts-mode-insert-return:
>
> ```
> func f() (x, y, z int) {
> return 0, 0, 0
> }
>
> func exotic() (bool, int, myStruct, *int, chan bool, error) {
> return false, 0, myStruct{}, nil, nil, err
> }
>
> func closure(numbers []int) {
> sort.Slice(numbers, func(i, j int) bool {
> return false
> })
> }
> ```
>
> The command go-ts-mode-insert-return is experimentally bound to a key
> C-c C-r ("r" as return statement). It's a user error to run C-c C-r
> outside of a function body.
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?
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.