Subject: bug#36307: 26.2; Interaction between electric-pair and electric-quote

From: Gustavo Barros <[email-masked]>
Date: Mon, 19 Apr 2021 16:55:42 -0300

Hi João,

On Mon, 19 Apr 2021 at 16:16, João Távora <[email-masked]> wrote:

> After reading your issue in diagonal, it seems it's to do with
> electric-quote-mode and electric-pair-mode.  I wrote the latter
> mostly, but I didn't write the former, which I think is only for
> UTF-8 quotes.  I personally turn it off.  I don't think it respects
> the auto-balancing ideas I put into electric-pair-mode.
>
> (if that's even what you're asking about, I still haven't read and
> processed all your text).
>

Thanks for answering.

Yes, the TL;DR is: `electric-pair-mode' ignores 
`electric-pair-inhibit-predicate' and 
`electric-pair-skip-whitespace-function' when the input character is not 
of syntax class `(?\( ?\" ?\$)'.

This indeed affects `electric-quote-mode', thought the problem is in 
`electric-pair-mode' and should be dealt with there since the check 
happens in `electric-pair-post-self-insert-function' which runs after 
`electric-quote-mode's post-self-insert-function.  As a matter of fact, 
the reproduction example in the full report shows a case where 
`electric-pair-mode' fails for this reason by itself, without 
`electric-quote-mode'.  The case is `text-mode' where "\"" is of syntax 
class punctuation (not string), so that the pairing is never inhibited.

And I'm fine with whatever is your timing for this.  I had been living 
with half measures for a couple of years now, and now that I understood 
the problem better I could come up with a better local workaround (no 
good for a proper fix, unfortunately).  I really just reported back 
because it would be nice if this was fixed upstream.

Best regards,
Gustavo.

PS: I wrote in the report:

> What I failed to get when I originally reported is that, given the 
> depths set at each of these modes' hooks, 
> `electric-indent-post-self-insert-function' runs before 
> `electric-pair-post-self-insert-function'.

And I meant "`electric-quote-post-self-insert-function' runs before 
`electric-pair-post-self-insert-function'".  It was a copy-paste 
mistake, `electric-indent-mode' is out of the picture here altogether.