Function: delete-selection-mode

delete-selection-mode is an autoloaded, interactive and byte-compiled function defined in delsel.el.gz.

Signature

(delete-selection-mode &optional ARG)

Documentation

Toggle Delete Selection mode.

When Delete Selection mode is enabled, typed text replaces the selection if the selection is active. Otherwise, typed text is just inserted at point regardless of any selection.

See delete-selection-helper and delete-selection-pre-hook for information on adapting behavior of commands in Delete Selection mode.

This is a global minor mode. If called interactively, toggle the Delete-Selection mode mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is toggle. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer, evaluate (default-value \=delete-selection-mode)'.

The mode's hook is called both when the mode is enabled and when it is disabled.

View in manual

Probably introduced at or before Emacs version 20.1.

Key Bindings

Aliases

pending-delete-mode

Source Code

;; Defined in /usr/src/emacs/lisp/delsel.el.gz
;;;###autoload
(define-minor-mode delete-selection-mode
  "Toggle Delete Selection mode.

When Delete Selection mode is enabled, typed text replaces the selection
if the selection is active.  Otherwise, typed text is just inserted at
point regardless of any selection.

See `delete-selection-helper' and `delete-selection-pre-hook' for
information on adapting behavior of commands in Delete Selection mode."
  :global t :group 'editing-basics
  (if (not delete-selection-mode)
      (remove-hook 'pre-command-hook 'delete-selection-pre-hook)
    (add-hook 'pre-command-hook 'delete-selection-pre-hook)))