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


View this message in rfc822 format

From: Wilhelm Kirschbaum <wkirschbaum <at> gmail.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 62536 <at> debbugs.gnu.org, mou.tong <at> outlook.com
Subject: bug#62536: 30.0.50; Can we add """ ... """ electric pair in elixir, just like python
Date: Tue, 04 Apr 2023 19:54:45 +0200
Hi João,

>>
>> I had a look and don't see how without changing elec-pair.el 
>> that
>> there
>> is a more elegant way to do this.  I am happy with the current
>> patches
>> to be installed and then perhaps if there is a better way we 
>> can
>> apply
>> it to both python-mode and elixir-ts-mode later.
>
> It seems what you are trying to do is actually a functionality
> of electric-layout-mode,  right? It's creating newlines between
> two sets of '"""' so that if the user types one newline between
> them, then one extra newline is inserted after and the line is
> indented one level deeper than the '"""'.
>
> If so, it would seem like 'electric-layout-rules' would be a 
> good
> match.  The behaviour would happen _only_ if the user has
> electric-layout-mode, which is the standard Emacs mode for
> controlling this kind of electricity.  The last paragraph
> of the docstring of 'electric-layout-rules' seems to describe
> a powerful enough mechanism to do achieve what the custom
> psif does.
>
> João

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.

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?

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?  I don't know if many people 
using
elixir-ts-mode will know about the electric layout mode and might 
get annoyed with
electric-pair-mode for heredocs ( tripple quote pairs ). 




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.