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: Thu, 09 Feb 2023 15:39:55 +0200 Message-ID: <83357flzys.fsf@gnu.org> References: <83edr0nmq6.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24765"; 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 Thu Feb 09 14:41:33 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 1pQ7B7-0006Ir-Hp for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 09 Feb 2023 14:41:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQ7Ae-0004ae-Eh; Thu, 09 Feb 2023 08:41:04 -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 1pQ7Ad-0004Zx-CX for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2023 08:41:03 -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 1pQ7Ad-0003la-4O for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2023 08:41:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pQ7Ac-0004aq-H9 for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2023 08:41:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 09 Feb 2023 13:41:02 +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.167595003517610 (code B ref 61368); Thu, 09 Feb 2023 13:41:02 +0000 Original-Received: (at 61368) by debbugs.gnu.org; 9 Feb 2023 13:40:35 +0000 Original-Received: from localhost ([127.0.0.1]:57938 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQ7AA-0004Zx-S0 for submit@debbugs.gnu.org; Thu, 09 Feb 2023 08:40:35 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:39630) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQ7A8-0004Zb-KA for 61368@debbugs.gnu.org; Thu, 09 Feb 2023 08:40:33 -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 1pQ7A0-0003d5-6W; Thu, 09 Feb 2023 08:40:26 -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=wPbpxefi8evV2B+m6L+EqIsMK9GlyUb9s770kYvV+0g=; b=pLeaweVTTLdt bo2tQLugi6yXGHFfB89VKtjqVXHTuMAuSlySygNttYJa3Clu/hDuOHQmWcLQ5RAELEaDs81E/bbPU 5edQWeWtQcDkYsXSDV5vCbu/zAkb1d9wuKkyaeyxEv8O3FOcon4gM1k//7ohMD0olHHAtLanBbjMZ x/vuRrNDXSr3TZz1gk5v82+rX4sDQRXAHBL3Fp2lpufB1cH8pPPM5ctT7y2aZLOl+MGFO0zAjZ9di n9/zuA2nky3rxMqtp29J3kU/TMM64cLaiLXjIGodAclZGfizsN4oBqynOMPB/p8OY4Qc1foTQksCI d0l9TUPDHVVWbaHegcoK2w==; 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 1pQ79h-0003XN-HF; Thu, 09 Feb 2023 08:40:23 -0500 In-Reply-To: (message from Evgeni Kolev on Thu, 9 Feb 2023 13:47:01 +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:255218 Archived-At: > From: Evgeni Kolev > 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.