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

From: João Távora <[email-masked]>
Date: Thu, 06 Apr 2023 01:17:06 +0100

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?

> 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.

>
> 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

> (define-derived-mode elixir-ts-mode prog-mode "Elixir"
>   "Major mode for editing Elixir, powered by tree-sitter."
> @@ -630,7 +648,8 @@ elixir-ts-mode
>                     ( elixir-sigil elixir-string-escape
>                       elixir-string-interpolation ))))
>
> -    (treesit-major-mode-setup)))
> +    (treesit-major-mode-setup)
> +    (setq-local syntax-propertize-function
> #'elixir-ts--syntax-propertize)))

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