Subject: bug#62536: 30.0.50; Can we add """ ... """ electric pair in elixir, just like python

From: Wilhelm Kirschbaum <[email-masked]>
Date: Thu, 06 Apr 2023 07:39:54 +0200

> Wilhelm Kirschbaum <[email-masked]> writes:
>
>> Thanks, yes.  I think this brings us closer.
>
> Yes, though keep in mind that needs that patch to 
> lisp/electric.el, or
> some other mechanism that allows electric-layout-mode to happen 
> in
> strings or coments.  If this mechanism is needed, I don't think 
> it is a
> lot of work to implement it.
>
> But who knows if the text inside the '""" """' should _not_ be
> considered a string or comment class at all?
>

I will spend some time in the next couple of days to familiar 
myself a
bit more with he electric modes and can hopefully weigh in as 
well.

If we can patch electric.el and make this change simpler it is 
still
preferable imo.

>> For some more fun, and the other part of the issue I have not
>> mentioned is this scenario:
>>
>> ```elixir
>> def foo() do
>>  ~H"""
>>  <foo class=
>>  """
>> end
>> ```
>>
>> then completing `class=""` jumps into the end of the template , 
>> which
>> is
>> pretty annoying, more so that the current issue at hand.
>
> Ah, I think you want to look at elec-pair's
> electric-pair-skip-whitespace (which is a user variable, but you
> major-mode could set it to nil) and the function
> electric-pair-skip-whitespace-function controlling how 
> whitespace is
> skipped.
>

Will try that, thanks.

>>
>> The other patch in this thread will porpertize the `"""` as
>> `$` for a lack of a better syntax class, which then breaks it 
>> again
>> and
>> produces:
>>
>> ```
>> """
>> |"
>> """
>> ```
>
> Maybe that means that the text inside the """ """ no longer is 
> "string
> or comment".  Can you evaluate `(syntax-ppss)` inside that block
>

(syntax-ppss) here is: (0 nil 1 nil nil nil 0 nil nil nil nil)

"""
|
"""

So does not see it as inside a string.

The triple quotes can either be a heredoc or a embedded template 
if
prefixed with ~H.

>
> I think at this point it would be a good idea for you to push 
> whatever
> is the "best" version of your code up to this point to a branch 
> in a Git
> repository somewhere, so that I can grab it, test it and try to 
> suggest
> simplification based on that.  Alternatively, attach patches 
> (but at
> least I sometimes get confused when there are multiple patchsets 
> in a
> thread).
>
> João

My current "working" version is here: 
https://git.sr.ht/~whk/emacs.
I rebase on there quite often though.