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

João Távora <[email protected]> Tue, 04 Aug 2026 22:21:29 +0100
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
Andrew Hyatt <[email protected]> writes:

> On Mon, Aug 3, 2026 at 5:37=E2=80=AFAM Jo=C3=A3o T=C3=A1vora <joaotavora@=
gmail.com> wrote:
>
>  Did someone test the candidate code with SLY's current e-p-m and comint =
integration? Is there any reason to think it
>  might break? I hope not.=20
>
> I think as long as SLY doesn't use fields in some strange way, it should =
be OK.  I haven't tested with SLY but if you let
> me know what e-p-m is and how to test it, I can test it out.

e-p-m is electric-pair-mode.  To test with SLY you need a Common Lisp
implementation, such as sbcl.  Then it could (should?)  be as easy as

    sudo pacman -S sbcl # or however you install packages, this is for Arch=
Linux
    git clone https://github.com/joaotavora/sly.git
    cd sly
    path/to/patched/emacs -Q -L . -l sly-autoloads -f eletric-pair-mode -f =
sly

which should land you in a SLY Lisp REPL (not unlike Elisp's IELM).

    CL-USER> (prin1 "blabla ( forgot to close")
    "blabla ( forgot to close"
    "blabla ( forgot to close"
    CL-USER> (closing a parenthesis here should skip, despite the output)

That's it.
>=20=20
>=20=20
>  If SLY decides to migrate to the new style of comint integration (presum=
ing there is one, at least that's where I saw
>  the discussion headed) is there a manual or example to follow?
>
> I don't think there's anything SLY would need to do, as long as it is usi=
ng comint in the normal way, which automatically
> uses different fields for non-user input and prompts, and user-inputs
> are not in a field at all.

That's nice :-)

As far as I understand, you are confident your patch is 100%
backward-compatible, right?  Also, do you think you could code it such
that the highlights only the restriction/wrapping part?

In other words, can you patch be expressed in term of a diff such as
this one?

@@ -597,6 +597,11 @@ electric-pair-default-inhibit
 (defun electric-pair-post-self-insert-function ()
+  (with-suitable-restriction-thingies ()
+    (let ((foo 42)...)
+      (electric-pair--post-self-insert-function-1))))
+
+(defun electric-pair--post-self-insert-function-1 ()
   "Do main work for `electric-pair-mode'.
 This function is added to `post-self-insert-hook' when
 `electric-pair-mode' is enabled.

If so, it'll be much easier to review and to understand by future maintaine=
rs.

Jo=C3=A3o