all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Wilhelm Kirschbaum <wkirschbaum@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	62536@debbugs.gnu.org, mou.tong@outlook.com
Subject: bug#62536: 30.0.50; Can we add """ ... """ electric pair in elixir, just like python
Date: Tue, 4 Apr 2023 19:39:10 +0100	[thread overview]
Message-ID: <CALDnm52V+cyiQ0NpoHh6BJmFaQdHVSm8RkzdhOKWgDa7TK_qjA@mail.gmail.com> (raw)
In-Reply-To: <87zg7nfrex.fsf@gmail.com>

On Tue, Apr 4, 2023 at 7:12 PM Wilhelm Kirschbaum <wkirschbaum@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.

And in electric-layout-rules you _can_, I think, identify
triple quotes using a function as described in the last
paragraph of its docstring.

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

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

But your suggestion to check for electric-layout-mode in the
custom psif leads to same situation, right?

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.

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





  reply	other threads:[~2023-04-04 18:39 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30  4:25 bug#62536: 30.0.50; Can we add """ ... """ electric pair in elixir, just like python 牟 桐
2023-03-30  5:44 ` Eli Zaretskii
2023-03-30  6:19   ` Wilhelm Kirschbaum
2023-03-30  8:25     ` bug#62536: 回复: " Mou Tong
2023-04-02  7:49     ` Wilhelm Kirschbaum
2023-04-02 16:38       ` Mou Tong
2023-04-02 17:21         ` Wilhelm Kirschbaum
2023-04-02 19:24           ` Wilhelm Kirschbaum
2023-04-03  2:41             ` Mou Tong
2023-04-03  8:26               ` Wilhelm Kirschbaum
2023-04-03  9:42                 ` bug#62536: 回复: " Mou Tong
2023-04-03 10:38                   ` Wilhelm Kirschbaum
2023-04-03 12:02                 ` João Távora
2023-04-03 12:08                   ` Wilhelm Kirschbaum
2023-04-03 14:02                 ` Eli Zaretskii
2023-04-03 14:17                   ` Wilhelm Kirschbaum
2023-04-03 14:38                     ` Eli Zaretskii
2023-04-04  5:39                       ` Wilhelm Kirschbaum
2023-04-04  9:08                         ` João Távora
2023-04-04 17:54                           ` Wilhelm Kirschbaum
2023-04-04 18:39                             ` João Távora [this message]
2023-04-04 19:03                               ` Wilhelm Kirschbaum
2023-04-04 19:46                                 ` Wilhelm Kirschbaum
2023-04-04 20:29                                 ` Wilhelm Kirschbaum
2023-04-05 13:09                                   ` João Távora
2023-04-05 14:33                                   ` João Távora
2023-04-05 17:28                                     ` Wilhelm Kirschbaum
2023-04-06  0:17                                       ` João Távora
2023-04-06  5:39                                         ` Wilhelm Kirschbaum
2023-04-06 10:07                         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALDnm52V+cyiQ0NpoHh6BJmFaQdHVSm8RkzdhOKWgDa7TK_qjA@mail.gmail.com \
    --to=joaotavora@gmail.com \
    --cc=62536@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=mou.tong@outlook.com \
    --cc=wkirschbaum@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.