From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#61368: [PATCH] Extend go-ts-mode with support for pre-filling return statements Date: Wed, 08 Feb 2023 18:30:41 +0200 Message-ID: <83edr0nmq6.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38697"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dev@rjt.dev, theo@thornhill.no, 61368@debbugs.gnu.org To: Evgeni Kolev Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 08 17:31:46 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pPnMI-0009uZ-6d for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Feb 2023 17:31:46 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPnM3-0001h1-B2; Wed, 08 Feb 2023 11:31:31 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPnLa-0001dQ-Fe for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2023 11:31:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pPnLa-0002s9-4J for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2023 11:31:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pPnLZ-00054Q-Qg for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2023 11:31:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Feb 2023 16:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61368 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 61368-submit@debbugs.gnu.org id=B61368.167587383419454 (code B ref 61368); Wed, 08 Feb 2023 16:31:01 +0000 Original-Received: (at 61368) by debbugs.gnu.org; 8 Feb 2023 16:30:34 +0000 Original-Received: from localhost ([127.0.0.1]:56481 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPnL7-00053h-Ip for submit@debbugs.gnu.org; Wed, 08 Feb 2023 11:30:33 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:37030) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPnL3-00053O-Nn for 61368@debbugs.gnu.org; Wed, 08 Feb 2023 11:30:32 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPnKx-0001Tl-OP; Wed, 08 Feb 2023 11:30:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=1fIsDX8gvJyxcR8Pdhg95blb4yEHM0Geu7LqdkYiyD8=; b=ppni7rf5ADHP GVdizalj0Baaq8SoKOryD/kjnEOp9Yzd/zFN3siwPp4yHZgcpJVnxK3sWv58moyJ0C3cXDOt+8YwT 4ayoIU3KcmVfD11j4VeuF8J9E2g+1WkcqUKwOxt1YyFM7RB6Ey51ktNMdvjMV3PgNvbdv9GFY0Afx kk4pKtJit0rlB3QtmQGBI3Noqj2f4SRX0ozD9awjwCQEbhlWcxOSNcVBkzZz1fuKKw0my82OvN4/2 eXjIfbcbisyP1g96zw4zYd3HkXc3+dTEf/9Mjw1Fd+dPTRteM9iCrLCiyuUdmXswJbkMuGPkat/C5 qHq8PgaiCOsTuJM/2XBRCg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPnKx-0007fX-7y; Wed, 08 Feb 2023 11:30:23 -0500 In-Reply-To: (message from Evgeni Kolev on Wed, 8 Feb 2023 17:27:58 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:255153 Archived-At: > Cc: Randy Taylor , Theodor Thornhill > From: Evgeni Kolev > 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?