bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Wilhelm Kirschbaum
Subject: bug#62536: 30.0.50; Can we add """ ... """ electric pair in elixir, just like python
Date: Sun, 02 Apr 2023 09:49:20 +0200
User-agent: mu4e 1.9.3; emacs 30.0.50


Wilhelm Kirschbaum <wkirschbaum@gmail.com> writes:

From: 牟 桐 <mou.tong@outlook.com>
Date: Thu, 30 Mar 2023 04:25:07 +0000
In elixir, the docs in src are like this:
``` elixir-ts-mode
defmodule Foo do
  @moduledoc """
  Foo-related functions.
  ## Examples
      iex> Foo.sum(1, 2)
      3
  """
  @doc """
  Calculate the sum of two numbers.
  """
  def sum(a, b), do: a + b
end
```
In python-mode, input the continious triple quotes, it will insert
the
left quotes when electric-pair-mode is on.
python-mode did it here:
https://github.com/emacs-mirror/emacs/blob/bfa3500c3c6e4df58978e84753718cd5358c06fb/lisp/progmodes/python.el#L6599-L6607
https://github.com/emacs-mirror/emacs/blob/bfa3500c3c6e4df58978e84753718cd5358c06fb/lisp/progmodes/python.el#L6637-L6639
This behavior is also very common in elixir, so can we add this to
elixir-ts-mode? thx

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?

Instead of this:

(save-excursion
     (insert (make-string 2 last-command-event)))

perhaps this:

(save-excursion
     (newline)
     (insert (make-string 2 last-command-event)))
(newline)

Then the when you type

@moduledoc """

it will jump to

@moduledoc """
|
"""

instead of
@moduledoc """|""" I am adding two patches, one for the electric pair and another to fix the issue where the point jumps to the end of a multi-line comment when
type `"` within the multi-line comment.

Attachment: 0001-Propertize-heredocs-in-elixir-ts-mode.patch
Description: Propertize heredocs

Attachment: 0002-Handle-electric-heredocs-pairs-in-elixir-ts-mode.patch
Description: Handle electric heredocs


reply via email to

[Prev in Thread] Current Thread [Next in Thread]