GNU bug report logs - #62536
30.0.50; Can we add """ ... """ electric pair in elixir, just like python

Previous Next

Package: emacs;

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 #26 received at 62536 <at> debbugs.gnu.org (full text, mbox):

From: Wilhelm Kirschbaum <wkirschbaum <at> gmail.com>
To: Mou Tong <mou.tong <at> outlook.com>
Cc: "62536 <at> debbugs.gnu.org" <62536 <at> debbugs.gnu.org>
Subject: Re: bug#62536: 30.0.50; Can we add """ ... """ electric pair in
 elixir, just like python
Date: Sun, 02 Apr 2023 21:24:24 +0200
> Mou Tong <mou.tong <at> outlook.com> writes:
>
>>> Will it make sense to also add a newline when closing a 
>>> multiline
>>> comment/heredoc? It feels smoother to me rather than having to
>>> press
>>> enter and then C-o ( open-line ) to position the cursor 
>>> correctly?
>>
>> I agree with you, but I think it might be better to imitate 
>> what
>> `c-mode` did:
>>
>> ```c
>> int main () {|}
>> ```
>>
>> When `electric-pair-mode` is on, input the left `{`, Emacs 
>> helps you
>> complete the right `}`. After press enter, your cursor will 
>> move to
>> the
>> next line and auto-indented according to your offset config:
>>
>> ```c
>> int main () {
>>   |
>> }
>> ```
>>
>> So how about making it work like this?
>>
>> ```elixir-ts
>> @doc """|"""
>>
>> # after press enter
>> @doc """
>>   |
>> """
>> ```
>
> Yes, I think that is better, let me have a go at it.  I was 
> concerned
> of doing unsolicited movement with my suggestion of inserting
> newlines.

Playing around with it I think we should add a newline, I changed 
my mind.

Unlike the c example above, the following syntax is not valid 
elixir: `""""""` and it requires a
newline to make it valid.  Part of the appeal of making the 
heredoc electric is to keep
the syntax valid.  There should never be a reason for the heredoc 
to be
on a single line and also makes the tree-sitter grammar invalid, 
which
causes the blinking issue.

This will mean:

```
@doc ""|
```

when typing `"` it will insert `\n"""` and thus have the minimal 
valid elixir
syntax without doing extra movement.

```
@doc """|
"""
```

This will be the change ( looking at the electric.el code ).




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.