RE: delete-selection-mode

From:

Drew Adams

Subject:

RE: delete-selection-mode

Date:

Thu, 29 Apr 2010 12:47:32 -0700

> > With the ability to yank it back, or without?
> >
> > The ability to delete text w/o any way to recover it would
> > be a disaster.
> >
> > And I haven't been able to deduce the answer to that
> > question from the various posts on the various threads
> > which I've read.
> >
> > If the deleted text /can/ be yanked back, then your
> > proposal is welcome.
> >
> > (Even though I used the work yank, recovery via (undo) also
> > would do.)
>
> I don't see how it would be a disaster not to be able to yank it back.
> You would still be able to kill-region with C-w.
>
> I'm in favor of making DEL delete the selection (*not* killing it).
> Not being able to "undo" back text after deleting it would be a
> terrible idea, but I'd doubt anyone is suggesting we do that.
`delete-selection-mode' has always acted the way you request: delete, not kill
for DEL.
;; 'supersede
;; Delete the active region and ignore the current command,
;; i.e. the command will just delete the region.
(put 'delete-backward-char 'delete-selection 'supersede)
(put 'backward-delete-char-untabify 'delete-selection 'supersede)
(put 'delete-char 'delete-selection 'supersede)
And any user can easily change the behavior. Just put this in your .emacs if you
want DEL to kill the region:
(put 'delete-backward-char 'delete-selection 'kill)
(put 'backward-delete-char-untabify 'delete-selection 'kill)