Subject: bug#79047: Add some multi-character pairs to some major modes.

From: Alan Mackenzie <[email-masked]>
Date: Fri, 25 Jul 2025 11:42:37 +0000

Hello, Eli.

On Fri, Jul 25, 2025 at 14:08:43 +0300, Eli Zaretskii wrote:
> > Date: Fri, 25 Jul 2025 10:32:15 +0000
> > Cc: [email-masked], [email-masked], [email-masked],
> >   [email-masked], [email-masked]
> > From: Alan Mackenzie <[email-masked]>

> > > And as I already mention, you perceive a convention where there is
> > > none.

> > OK, then, Emacs hackers have abided by this non-convention nevertheless,
> > out of instinctive good sense and good taste.  Up until
> > post-self-insert-hook.

> Which might mean there was no non-convention to begin with.

> > > Thus electric-pair-mode doesn't violate any conventions.

> > self-insert-command, called from Lisp, is broken.  There is no usable
> > definition of its functionality.

> What's wrong with its doc string as that definition?

It's inaccurate and misleading.

We have:

    Insert the character you type.
    Whichever character C you type to run this command is inserted.
    [Plus all the bits about the numeric prefix, abbreviations, etc.]

More accurate would be:

    Maybe insert the character you type (depending on
    post-self-insert-hook).
    Insert or delete further characters as specified by
    post-self-insert-hook.
    Leave point at the position determined by post-self-insert-hook or
    after the inserted character.

..  This makes it unusable in a Lisp program.  For example, in
c-electric-paren, which handles the user entering "(" or ")", the code
needs to determine whether the "(" was entered at the end of a line.
The current self-insert-command, which inserts arbitrary further
characters, makes this difficult.

With the current self-insert-command, there is no satisfactory way of
coding c-electric-paren - only workarounds with varying degrees of
ugliness.

I am suggesting that self-insert-command should be made usable from Lisp
again, as it once was, and have suggested a means for achieving this.

-- 
Alan Mackenzie (Nuremberg, Germany).