Subject: bug#78053: [PATCH] Support strings for electric-pairs.

From: Rudolf Schlatte <[email-masked]>
Date: Thu, 12 Jun 2025 09:47:15 +0200

Eli Zaretskii <[email-masked]> writes:

>> From: Elijah Gabe Pérez <[email-masked]>
>> Cc: Stefan Monnier <[email-masked]>,  [email-masked],
>>   [email-masked]
>> Date: Sun, 08 Jun 2025 12:24:57 -0600
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> > Is the last patch okay to install?  If not, Elijah, would you please
>> > submit an updated patch?
>> 
>> Sure, I'm sending here a better version.
>> 
>> I made a few minor changes since I found several bugs.
>> If there are no objections, the patch is ready to be installed.
>
> Thanks, a few further minor comments:
>
>> +---
>> +** Electric pair mode now supports multi-character paired delimiters.
>> +This is done by supporting strings in electric-pair-pairs.
>
> the last sentence should be rewritten to tell users how to use this
> feature instead of how it was implemented.  For example:
>
>   To use this, customize 'electric-pair-pairs' to include the
>   delimiter strings.
>
> (Note that this also quotes symbols, like we do in NEWS.)
>
>>  See also the variable `electric-pair-text-pairs'."
>>    :version "24.1"
>>    :group 'electricity
>> -  :type '(repeat (cons character character)))
>> +  :type '(repeat
>> +          (choice (cons :tag "Characters" character character)
>> +                  (cons :tag "Strings" string string)
>> +                  (list :tag "Strings and insert space in pairs"
>> +                        string string boolean))))
>
> What does "Strings and insert space in pairs" mean?  This tag is IMO
> unclear, and we should clarify it.

FWIW, I'd love to have this customizable instead of being a hard-coded
space character.  The use case is the multi-line strings of recent Java
versions, which start with three quotation marks (") and a mandatory
line break, and end with three quotation marks.

String exampleString = """
      This is a muli-line Java string.  The shortest sequence of leading
      white space (4 spaces in this case) will be ignored.
      """;

It would be nice if, in java-mode, after typing three quotation marks
the buffer would end up like this (with "|" denoting the cursor
position):

String exampleString = """
    |"""