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

From: Eli Zaretskii <[email-masked]>
Date: Thu, 24 Jul 2025 17:53:55 +0300

> Date: Thu, 24 Jul 2025 13:39:16 +0000
> Cc: [email-masked], Eli Zaretskii <[email-masked]>,
>   John Muhl <[email-masked]>, Stefan Monnier <[email-masked]>
> From: Alan Mackenzie <[email-masked]>
> 
> Yes, sort of.  But electric pair mode's implementation violates an
> (unwritten) Emacs convention about hooks, i.e. that a hook function
> doesn't mess with the functionality that invoked it.  For example, a
> function in window-scroll-functions may not change the scrolling state of
> a window, and an after-change-functions function never changes the text
> of a buffer.
> 
> By contrast, electric-pair-post-self-insert-function does mess with the
> invoking functionality, namely self-insert-command; it inserts further
> characters.  From the point of view of a Lisp program, this makes
> self-insert-function an undefined function - what it does varies from
> time to time and from buffer to buffer.

?? post-self-insert-hook is specifically mean for features that insert
additional characters, or even replace characters by others.
Otherwise, what would that hook be good for?

The ELisp manual says about this: "You could use this to automatically
reindent text as it is typed, for example."  And what is reindentation
if not removal of some characters and insertion of others?

So I don't understand the nature of your dislike in this case.