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

From: "Elijah G." <[email-masked]>
Date: Mon, 16 Jun 2025 16:39:56 -0600

Rudolf Schlatte <[email-masked]> writes:

> Elijah Gabe Pérez <[email-masked]> writes:
>
>> Eli Zaretskii <[email-masked]> writes:
>>
>>>> This is a kind of property for pairs (only for strings pairs),
>>>> that
>>>> tells to `electric-pairs` to insert a space before the first pair.
>>>> 
>>>> I couldn't find a better way to document this in that limited-size
>>>> tag.
>>>
>>> If you explain to me what it does, I can try finding more clear
>>> wording.
>>
>> That must be a list of 3 elements where specifies: pair start, pair
>> end,
>> and a non-nil value which specifies to insert an extra space after
>> `pair
>> start` was typed.
>>
>> Thus, if electric-pair-pairs is set like this:
>> (setq electric-pair-pairs '(("/*" " */" t)))
>>
>> After the pair start was typed it expands to this:
>> /* | */
>>    ^ cursor
>
> Instead of hard-coding the extra space, how about allowing the third
> element to also be a string, with that string being inserted after the
> pair start?  In java-mode, I'd then add an element ("\"\"\"" "\"\"\""
> "\n") since Java-style multi-line strings start with a mandatory
> linebreak after the opening triple-quote.

That is already possible setting it to this:

("\"\"\" . "\n\"\"\"")
            ^^

The extra space option is not hardcoded and can be ignored in the
electric-pairs alist.

That is done for center the cursor when some pairs requires extra spaces
(mostly because style), I find it useful for most block comments
(e.g. C /* | */), but there may be more cases where this can also be useful

So there's no need to add another option to the list.

-- 
- E.G via GNU Emacs Android port.