-(defvar delete-selection-mode t
- "*Non-nil means Delete Selection mode is enabled.
-In Delete Selection mode, when a region is highlighted,
-insertion commands first delete the region and then insert.")
+;;;###autoload
+(defalias 'pending-delete-mode 'delete-selection-mode)
+
+;;;###autoload
+(defun delete-selection-mode (&optional arg)
+ "Toggle Delete Selection mode.
+With prefix ARG, turn Delete Selection mode on if and only if ARG is
+positive.
+
+When Delete Selection mode is enabled, Transient Mark mode is also
+enabled and typed text replaces the selection if the selection is
+active. Otherwise, typed text is just inserted at point regardless of
+any selection."
+ (interactive "P")
+ (setq delete-selection-mode (if arg
+ (> (prefix-numeric-value arg) 0)
+ (not delete-selection-mode)))
+ (if (not delete-selection-mode)
+ (remove-hook 'pre-command-hook 'delete-selection-pre-hook)
+ (add-hook 'pre-command-hook 'delete-selection-pre-hook)
+ (transient-mark-mode t)))
+
+;;;###autoload
+(defcustom delete-selection-mode nil
+ "Toggle Delete Selection mode.
+See command `delete-selection-mode'.
+You must modify via \\[customize] for this variable to have an effect."
+ :set (lambda (symbol value)
+ (delete-selection-mode (or value 0)))
+ :initialize 'custom-initialize-default
+ :type 'boolean
+ :group 'editing-basics
+ :require 'delsel)