bug#50236: 27.2; electric-pair-mode is inconvenient in comint

Augusto Stoffel <[email protected]> Tue, 04 Aug 2026 21:24:25 +0200
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
On Sun, 19 Jul 2026, Andrew Hyatt wrote:

> Augusto Stoffel <[email protected]> writes: 
>
>  Hi Andrew, 
>
>  in your proposed patch, why did you choose to change
>  electric-pair-post-self-insert-function directly and not
>  electric-pair-default-skip-self (or even define a skip-self function specifically for
>  comint)? 
>
> Isn't skip-self for avoiding two closing parens in a row? This doesn't seem related to the
> problem. 

It is definitely related to the issue I originally reported in this bug
[1].

My suggestion was to define e.g.

   (defun electric-pair-skip-in-field (char)
     (save-restriction
       (narrow-to-region (field-beginning) (field-end))
       (electric-pair-default-skip-self char)))

and then, in comint-mode and wherever else it's suitable,

   (setq-local electric-pair-skip-self #'electric-pair-skip-in-field)

This fixes at least my test case.  What is again your test case?

[1] https://yhetil.org/emacs-bugs/[email protected]/