GNU bug report logs -
#62536
30.0.50; Can we add """ ... """ electric pair in elixir, just like python
Previous Next
Reported by: 牟 桐 <mou.tong <at> outlook.com>
Date: Thu, 30 Mar 2023 04:31:02 UTC
Severity: normal
Found in version 30.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #71 received at 62536 <at> debbugs.gnu.org (full text, mbox):
> On Tue, Apr 4, 2023 at 7:12 PM Wilhelm Kirschbaum
> <wkirschbaum <at> gmail.com> 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
>> elixir,
>> otherwise the font and navigation breaks because `""""""` is
>> not
>> valid
>> Elixir syntax and the tree-sitter grammar really does not like
>> it.
>
> I see. My apologies for not having noticed this in the
> 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
>> 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 :)
> You can choose to turn on electric-layout-mode by default
> locally in elixir-ts-mode if you want to give your users this
> 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
> without
> electric-pair-mode you type a '{' and the buffer is
> 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ão
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
electric-pair
as with electric-layout to identify more than just the last typed
char?
This will mean that we can entirely get rid of custom psifs and
think it
will be useful in at least 1 more mode.
This bug report was last modified 2 years and 48 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.