Subject: Re: bug#11520: 24.1.50; delete-selection-mode conflicts with electric-pair-mode

From: Stefan Monnier <[email-masked]>
Date: Wed, 18 Jul 2012 08:13:51 -0400

> That way, electric-pair-mode can override the (put
> 'self-insert-command 'delete-selection ...) with its own function that
> understands the triggering condition. The triggering condition would
> be extracted from electric-pair-post-self-insert-function so it could
> be used in two places.

That sounds like a reasonable plan, yes.

An alternative is to change self-insert-command so that it pays
attention to delete-selection-mode (and provides some hook for
electric-pair-mode to indicate when it would use the region).

> P.S. I don't have an bzr checkout of Emacs right now. Would this be
> something useful to target against Emacs 24 as a bugfix?

Yes.

        Stefan

PS: I don't much like delete-selection-mode because of its implementation
strategy (using a pre-command-hook along with symbol properties, as
opposed to modifying the commands themselves).  I can fully understand
why it was done this way, but I'd be happy to see it changed, along the
same lines as what we did for the shift-select-mode.

AFAICT, of the various `delete-selection' properties, `kill' is only
used for `open-line' (for no good reason) and could be eliminated.
`supersede' is only used by command which should obey
`delete-active-region' or close enough, `yank' is only used for commands
which end up calling `yank' (so adding code to the `yank' command would
cover them), and t is used for commands which end up calling
`self-insert-command' (with a few minor exceptions like open-line).