Subject: Re: bug#72437: Unexpected behavior when inserting with prefix arg in electric-pair-mode

From: Eli Zaretskii <[email-masked]>
Date: Sat, 03 Aug 2024 12:12:06 +0300

> Cc: [email-masked]
> From: Joseph Turner <[email-masked]>
> Date: Sat, 03 Aug 2024 00:12:33 -0700
> 
> Migrated from this thread on the devel mailing list:
> 
> https://yhetil.org/emacs-devel/[email-masked]/T/#t
> 
> 
> On Emacs 29.4, with emacs -Q
> 
> Turn on electric-pair-mode
> 
> (electric-pair-mode +1)
> 
> Then press "C-2 ("
> 
> Expected result:
> 
> Either (()) or ()()
> 
> Actual result:
> 
> (()
> 
> 
> I noticed the unexpected behavior when attempting to surround some text
> with multiple braces in order to create Anki flashcards.
> 
> More or less, I wanted to go from "foo" to "{{foo}}", and I thought
> perhaps that with the whole word selected, pressing "C-2 {" would DTRT.
> 
> In general, I'm not sure whether "{}{}" or "{{}}"is more useful or
> expected, but I suspect both are better than "{{}".

Making it produce "{}{}" is relatively easy: we just need to call the
post-self-insert-hook for each of the ARG inserted characters.  OTOH,
to produce "{{}}" we'd probably need to rewrite the
electric-pair-mode's hook function, but I have no idea how to rewrite
it to do that.

Stefan, any suggestions?