From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Wilhelm Kirschbaum Newsgroups: gmane.emacs.bugs Subject: bug#62536: 30.0.50; Can we add """ ... """ electric pair in elixir, just like python Date: Tue, 04 Apr 2023 21:03:36 +0200 Message-ID: <87v8ibfnke.fsf@gmail.com> References: <83sfdm6bet.fsf@gnu.org> <87edp6oim6.fsf@gmail.com> <87lejay8n3.fsf@gmail.com> <06DAF2C4-C224-4C30-AAAE-96D1A84ED145@outlook.com> <87bkk642k0.fsf@gmail.com> <87edp2vzvg.fsf@gmail.com> <87h6tx74i4.fsf@gmail.com> <83y1n9ukqb.fsf@gnu.org> <83o7o5uj2c.fsf@gnu.org> <871ql06w59.fsf@gmail.com> <87zg7nfrex.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22608"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.9.3; emacs 30.0.50 Cc: Eli Zaretskii , 62536@debbugs.gnu.org, mou.tong@outlook.com To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 04 21:36:35 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 1pjmSJ-0005lp-8C for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 Apr 2023 21:36:35 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pjmRt-0004UH-0t; Tue, 04 Apr 2023 15:36:09 -0400 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 1pjmRr-0004Ti-Kp for bug-gnu-emacs@gnu.org; Tue, 04 Apr 2023 15:36:07 -0400 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 1pjmRn-0006xY-K7 for bug-gnu-emacs@gnu.org; Tue, 04 Apr 2023 15:36:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pjmRn-0005fa-CB for bug-gnu-emacs@gnu.org; Tue, 04 Apr 2023 15:36:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Wilhelm Kirschbaum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Apr 2023 19:36:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62536 X-GNU-PR-Package: emacs Original-Received: via spool by 62536-submit@debbugs.gnu.org id=B62536.168063692521719 (code B ref 62536); Tue, 04 Apr 2023 19:36:03 +0000 Original-Received: (at 62536) by debbugs.gnu.org; 4 Apr 2023 19:35:25 +0000 Original-Received: from localhost ([127.0.0.1]:50258 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjmRA-0005eF-Sd for submit@debbugs.gnu.org; Tue, 04 Apr 2023 15:35:25 -0400 Original-Received: from mail-wr1-f48.google.com ([209.85.221.48]:39693) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjmR9-0005e0-01 for 62536@debbugs.gnu.org; Tue, 04 Apr 2023 15:35:23 -0400 Original-Received: by mail-wr1-f48.google.com with SMTP id m2so33967004wrh.6 for <62536@debbugs.gnu.org>; Tue, 04 Apr 2023 12:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680636917; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :subject:cc:to:from:user-agent:references:from:to:cc:subject:date :message-id:reply-to; bh=oGFV1jQUA6mfefds9m33Oqq3NdvoxSvC1/h0nrb+sK8=; b=jjBZlLHO7ggewCDTbjWOcw0hPpNhIIz8riNzMyseGpnWUc/tX6d36EAesvlZH9jSM9 FLTcg3/cBfNWMjIbHwawSacb6yK0zPzQ8oviK4QujW3jSc0kminOttgOmj0zqtxwqE8m VjJ6rYSLBoCUCJfSPhrvWIgO4yDTH/VIv1efp/UzKc/N4OI6UhnoARyHvA12ZYNqg5+E GtS9/HeEDWrMaSBLIIPayJnLb4P7rpDiitNBUYL/E4zYUhaBABCyGKVWqDmZIbU1Jhes nFR83wijbLy2nhf3VG/7Apjl7SvbL2ntBNLhLPg0wybkqyqGX/3fN7sPghUJ9N02AHsI HcMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680636917; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :subject:cc:to:from:user-agent:references:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=oGFV1jQUA6mfefds9m33Oqq3NdvoxSvC1/h0nrb+sK8=; b=bNtrn5uUtNIwq/XPJ3KkZgyGAMkKhOy5oROcq4xD0pQiSMy+zJL0ZxIzPsa3M2uZ3F 6OvV4zwrxJAUfBcYB5mwIDVVailG4lmmZSvaqt+qSj55eYIxth/RNpCynQUrCaY4xhtQ 9C2lBcuHWrVmextLmmaVKuUMEjOOPPLu8YqoYaFRJxXSpX8w+Rbpy/b4S3SS4GSimYO/ 21VBI3JbaMj1eEfEf0WpHvIWEdAIXJf0YfKD32gFo+eXsAi9c8VZ5YzexlAvbszDupoA S0Fo1Ru16HnWvpyW6RKTbQIWkOSMOrR7e4taqU3xk/BD41+I4MhyqJwM4cpngAcEGP6T G92g== X-Gm-Message-State: AAQBX9dtozwde9MXg8eBRW7dxZTZ5l5c3LiMeeZI0Z3SeeuUp/WklSnM CLNL5l89rh2e06MNQFLN1w4= X-Google-Smtp-Source: AKy350ZrjvZm/mcjosxZUAPCTWBapgjxy7W0odnxm6ukvxWswiH2xkphe/UG53LYhhMNmYpUtgjyoA== X-Received: by 2002:a5d:6291:0:b0:2d6:5afe:7b99 with SMTP id k17-20020a5d6291000000b002d65afe7b99mr2069662wru.10.1680636917097; Tue, 04 Apr 2023 12:35:17 -0700 (PDT) Original-Received: from melissa.local (ec2-13-245-80-249.af-south-1.compute.amazonaws.com. [13.245.80.249]) by smtp.gmail.com with ESMTPSA id t16-20020adfdc10000000b002e5ff05765esm12510164wri.73.2023.04.04.12.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 12:35:16 -0700 (PDT) In-reply-to: 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:259238 Archived-At: > On Tue, Apr 4, 2023 at 7:12=E2=80=AFPM Wilhelm Kirschbaum=20 > wrote: > >> The custom psif is not for the newline, but for pairing up the >> triple >> quotes `"""` with another set of tripe quotes when >> electric-pair-mode is >> enabled. The newline is for keeping the syntax valid in=20 >> elixir, >> otherwise the font and navigation breaks because `""""""` is=20 >> not >> valid >> Elixir syntax and the tree-sitter grammar really does not like=20 >> it. > > I see. My apologies for not having noticed this in the=20 > preceding > emails. If you want some kind of electricity so that typing the > third `"` results in two `"` and a newline getting added, then > that is completely new and probably does require a custom psif. > > If that's _not_ what is meant, read on. Else skip to last > paragraph. > >> Unless electric-indent-chars can identify the triple quotes, we >> need a >> custom psif regardless of other functionality, but I don't see >> this >> option. Maybe I am wrong and you can point me to this feature? > > Here, you'd not want electric-indent-chars, right? If you're > dealing with the necessity of electrically adding a newline > to maintain syntax correctness, you're looking for > electric-layout-mode and electric-layout-rules, not > electric-indent. > Right, makes sense. > And in electric-layout-rules you _can_, I think, identify > triple quotes using a function as described in the last > paragraph of its docstring. > Yes, I tested this earlier and it does work. >> If it does not make sense to add the newline as this might not=20 >> be >> expected behaviour when electric-layout-mode is not enabled, we >> can add >> a check before inserting the newline? > > Sure, but I'd say just use electric-layout-rules in that case. > You convinced me :)=20 > You can choose to turn on electric-layout-mode by default > locally in elixir-ts-mode if you want to give your users this=20 > sane > behaviour by default. > Is that a good idea? I have not used electric-pair-mode or electric-layout-mode enough to know how this impacts the workflow. > Like other electric-* modes, it's a mode that helps maintain > the buffer valid (for some meaning of "valid"). Just like=20 > without > electric-pair-mode you type a '{' and the buffer is=20 > syntactically > invalid until you fix it. The "annoyance" can be solved by > turning it on, unless it's on already. > > Anyway, I just wanted to call attention to these existing > facilities in Emacs that were designed to help out major-mode > authors so that ad-hoc solutions aren't replicated again > and again, making maintenance difficult. But, then again, > I understand that the facilities might not be as powerful > as I and Stefan (mostly Stefan, really) intended. Here, my > naive understanding of the matter tells me they are, but > if I'm wrong and using the custom psif gets the job done, > then don't take my suggestion as a blocker, especially if all > your patches are ready and good to go. We can always come > back to this later. > > Jo=C3=A3o Thanks for doing so, I am relatively new to hacking on Emacs, so appreciate the feedback. Is there perhaps a way we can allow a similar function for=20 electric-pair as with electric-layout to identify more than just the last typed=20 char? This will mean that we can entirely get rid of custom psifs and=20 think it will be useful in at least 1 more mode.