emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: delete-selection-mode as default


From: Drew Adams
Subject: RE: delete-selection-mode as default
Date: Fri, 7 Sep 2018 09:27:04 -0700 (PDT)

> I call it a design flaw because if whoever made it this way had given
> any thought to it, it would at least be customizable

Actually, beyond being customizable by configuring it to be on or
off by default, it is customizable (but not just by using Customize),
in a fine-grained way.

You can easily configure the behavior to use for any given command,
by putting a particular `delete-selection' property value on its symbol.

These are the possible `delete-selection' property values:

* `yank' - For commands that do a yank.  Ensures that the region
about to be deleted is not yanked.

* `supersede' - Delete the active region and ignore the current
command: the command just deletes the region.

* `kill' - `kill-region' is used on the selection, rather than
`delete-region'.  (Text selected with the mouse is
typically yankable anyway.)

* anything else non-nil - Deletes the active region prior to
executing the command, which inserts replacement
text.  This is the usual case.

Commands that insert text but do not have property
`delete-selection' (or commands for which it's value is nil)
do not delete the selection.

For example: 

;; Don't let `insert-char' delete the selection.
(put 'insert-char 'delete-selection nil)

More typically is the case where a library defines a new
editing command that it wants to make susceptible to
`delete-selection-mode'. For example:

;; Let delete-selection mode delete the region. 
(put 'icicle-delete-char 'delete-selection 'supersede)

Simple, elegant command-specific behavior. Trivial to
configure - for both users and libraries.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]