Subject: bug#18100: 24.4.50; Restore simplicity of (put 'self-insert-command 'delete-selection 'kill)

From: Drew Adams <[email-masked]>
Date: Thu, 24 Jul 2014 10:22:23 -0700 (PDT)

This is a followup to bug #13312, whose status is "Fixed in version
24.4".

The #13312 bug thread included this exchange between me and Juri Linkov:

>From me:
--------

  > But when you want put `kill' as the `delete-selection' property
  > then it's better to use this code:
  > (put 'self-insert-command 'delete-selection
  >      (lambda ()
  >        (and (not (run-hook-with-args-until-success
  > 		  'self-insert-uses-region-functions))
  > 	    'kill)))

  Maybe so, but that is not at all what the `delete-selection-mode' doc
  & comments tell users.  If this is a new requirement/guideline, then
  it needs to be documented.

  But I wonder why this must now be so.  In the past, a user could just
  put `kill' as the property.  The code does not seem so clean now.

  One of the benefits of the `delsel.el' design (and yes, along with
  those benefits come also some disadvantages) is its simplicity for
  users.

  This seems to go against that.  Is it really necessary?  Isn't there
  another way to accomplish the same thing (whatever that is), so we can
  keep the simple and clean design for users?

  What was the reason for introducing
  `self-insert-uses-region-functions'?  It seems it was only for
  `electric-pair-mode'.  IIRC, I wasn't too happy with that hack when it
  was done.  Now it seems to be dirtying (complicating) `delsel.el'.
  Isn't there a better way?

  But again, we should probably be discussing this elsewhere, since it
  does not seem to be only about this bug.

  ...

  Users should be able to `put' a single, understandable symbol as the
  `delete-selection' property value.  They should not need to fiddle
  with obscure lambda forms (or symbols whose names are not simple to
  understand).  Symbol `kill' is simple - it says that you want the
  region to be killed.

  This simplicity was the case before (`delsel.el' is old and simple).
  Someone introduced `electric-pair-mode', and then someone else
  complained about its interaction with `delete-selection-mode'.  The
  fix for that should not have involved screwing
  `delete-selection-mode', as seems to be the case so far.

Juri's reply:
-------------

  I think (run-hook-with-args-until-success
  'self-insert-uses-region-functions) could be moved to the body of
  `delete-selection-helper'.  Then the users again will enjoy the
  simplicity of (put 'self-insert-command 'delete-selection t)
  and (put 'self-insert-command 'delete-selection 'kill)

To which I replied: "That sounds good.  Thank you, Juri."

This new bug is about getting that fixed, IOW, restoring the ability to
use a simple `put' to configure `delete-selection-mode' behavior for a
given command, rather than having to jump through hoops with
incomprehensible lambda forms in the `put' value.  IOW not make users do
things like this:

> (put 'self-insert-command 'delete-selection
>      (lambda ()
>        (and (not (run-hook-with-args-until-success
> 		  'self-insert-uses-region-functions))
> 	    'kill)))

In GNU Emacs 24.4.50.1 (i686-pc-mingw32)
 of 2014-06-28 on ODIEONE
Bzr revision: 117431 [email-masked]
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/Devel/emacs/snapshot/trunk
 --enable-checking=yes,glyphs 'CFLAGS=-O0 -g3'
 LDFLAGS=-Lc:/Devel/emacs/lib 'CPPFLAGS=-DGC_MCHECK=1
 -Ic:/Devel/emacs/include''